arun
arun

Reputation: 57

why (HttpWebResponse)request.GetResponse() method returning status code 200 for Error Page?

(HttpWebResponse)request.GetResponse() method returning status code 200 for Error Page instead of status code 400.

The Url is

http://onlinehelp.microsoft.com/zh-cht/office365-smallbusinesses/hh911992.aspx

when we open the above url in browser, it showing error page with message "We're sorry! We were unable to service your request."

But the status code return from webresponse is 200.

I code wriiten for it is

HttpWebRequest request = (HttpWebRequest)WebRequest.Create(loclink);
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
code = (int)response.StatusCode; 

please help me to track this type of url?

Upvotes: 1

Views: 897

Answers (3)

dtsg
dtsg

Reputation: 4468

I've come up against this whilst trying to verify a security metrics issue with one of our sites.

The reason you get a 200 response and not a 400 is because the error is being handled by the server gracefully, rather than showing you the actual error page, it's catching it and redirecting you to a friendly "An unexpected error has occurred" page which will obviously show a 200 response.

To get the actual error code you can try requesting the page in Telnet via:

GET /zh-cht/office365-smallbusinesses/hh911992.aspx

Upvotes: 0

Heki
Heki

Reputation: 976

It feels wrong, to be honest. I've been there too and was equally confused.

It's a so-called "soft error page". It's because the webserver redirects you to that page when it hits an error instead of transmitting the actual error page.

Upvotes: 1

user854301
user854301

Reputation: 5493

Seems that this server doesn't force status code for error pages, so you could try to check that this page contains special elements/words.

Upvotes: 0

Related Questions