NewBie help.

  • Thread starter Thread starter archana
  • Start date Start date
A

archana

Hi all,

I am having confusion regarding following code:-

HttpWebRequest wr = (HttpWebRequest)WebRequest.Create( url );
WebResponse resp = wr.GetResponse();
MessageBox.Show(resp.ResponseUri.ToString());

Above code fails for some url. It was giving error 'The remote server
returned an error: (500) Internal Server Error.'
But i open that url is IE that url was getting opened properly.

So then i modified above code and added following line
wr.UserAgent ="Mozilla/4.0 (compatible; MSIE 6.0; Win32)";

those urls where working properly.

Can someone tell me why this is happening?

What is use of specifying useragent instead of null to above value.

Please help me asap.

Thanks in advance.
 
Apparently, those servers (or web applications) require a user-agent header
to properly process a request. The 500 server error indicates a server
error, which may be generated by the web server itself, or as a result of a
server application (such as ASP, PHP, CGI, etc) exception.

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Numbskull

Hard work is a medication for which
there is no placebo.
 
Back
Top