I'm not real familiar with that control but is it possible to call the GetReadyState() function? Just a thought I couldn't find much documentation.
My 2 cents...
Main Topics
Browse All TopicsHi,
I could not find any method or property which returns the HTTP status code in Internet Explorer control (IE 5.5). Currently I am guessing the status code by checking the title of the page.
Any help will be greatly appreciated.
Thanks.
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Specifically, what status are you trying to get? And if you get it, what would you want to do with it?
In you OnDocumentComplete handler, you can get access to the IHTMLDocument2 interface and perhaps learn something by scraping the contents. If nothing else, you can get the URL to see if it what you think it should be.
I don't see any clear way to get the actual HTTP status (eg, the 404 or 401 code). One possibility would be to provide an OnBeforeNavigate2 handler. Then use CHttpConnection/CHttpFile to pre-read the page and check for an error. If all is OK, then pass it on to the normal handler. But there could easily be a better way.
-- Dan
Thanks for the response guys.
I am working on an application which automates the browser and extracts the content of a page. To decide whether I have a valid page, http status code is a must.
Events like BeforeNavigate2, DocumentComplete etc is raised even for a failure condition. Parsing the title or content of a page to find the http status code is unreliable.
I cannot use CHttpFile because in case of secure pages (for example SSL), I have to handle all the authentication in my code. I am sure it is easier to let the browser do the job.
I still wonder why IE is hiding such a simple and important data like http status code. (considering the rich API it provides for parsing the page)
>>I cannot use CHttpFile because in case of secure pages
>>(for example SSL), I have to handle all the athentication
>>in my code. I am sure it is easier to let the browser do the job.
Given this, then I think you already know what is happeneing... the Webrbrowser control is doing exactly what you want it to do! It is handling the 40x errors for you!
By the time you get control at OnDocumentComplete, there *is* no HTTP error code for you to process (it would always be 200, "no error")
So now to solve your problem....
You are writing code to automate walking HTML pages, so there is no reason to use a Webrowser control at all -- unless you need a UI for display-only functionality. SO just drop-dwon to using CHTTPConnection and CHttpFile... but that leaves the problem of handling security such as HTTPS connections.
That turns out to be pretty easy....
After CHttpFile::SendRequest(), you can call pFile->QueryInfoStatusCode
http://msdn.microsoft.com/
Also, the "TEAR" sample on your MSDN disk shows most of what you need to do to grab pages without a web browser. This link to MS seems to be broken, but it might start working later:
80% TEAR: "Tearing" HTML Pages Off the Internet
http:// msdn.microsoft.com / library / en-us / vcsample98 / html / _sample_mfc_tear.asp
http://msdn.microsoft.com/
-==-=-=-=-=-
A reasonable compromise would be to use both methods -- a WebBrowser control in which you pre-access each URL in the OnBeforeNavigate2 handler. You have rejected this suggestion previously, so I won't bother to show you any sample code, but if you change your mind, let me know.
-- Dan
Hi Dan,
The solution you were suggesting doesn't fit my needs exactly. Also. it is quite an amount of work (my schedule doesn't permit it right now). I would rather try your points at my own leisure.
I have committed to give points anyway. I can as well give it you. If you have few samples, you can post it, it would be helpful.
Thanks.
Business Accounts
Answer for Membership
by: ShaunWildePosted on 2001-09-14 at 13:22:49ID: 6483752
what do you mean the 404 type response? the contents of the page is where it will be - the browser hides all inner workings and trnslates the status messages into a web page if it is an error.
If you need the raw status codes you will have to use the WinInet functions yourself - but that means you will have trouble rendering it