Why "(500) Internal Server Error" throwed?

A

Andy Chen

Hi,

When I am using the fowllowing code to open page
http://spaces.msn.com/members/mailcall/
....
try{
string url = http://spaces.msn.com/members/mailcall/;
HttpWebRequest httpReq = null;
HttpWebResponse httpResp = null;
httpReq = (HttpWebRequest)WebRequest.Create(url);
httpResp = (HttpWebResponse) httpReq.GetResponse();
}
catch(WebException ex)
{
....
}
....
I always got an WebException which says "The remote server returned an
error: (500) Internal Server Error". But actually if you open that page in
IE, it can be opened without any problem. How can I open this page in my
program and get the html source?

Any help would appreciate!

Andy
 
J

Joerg Jooss

Thus wrote Andy,
Hi,

When I am using the fowllowing code to open page
http://spaces.msn.com/members/mailcall/
...
try{
string url = http://spaces.msn.com/members/mailcall/;
HttpWebRequest httpReq = null;
HttpWebResponse httpResp = null;
httpReq = (HttpWebRequest)WebRequest.Create(url);
httpResp = (HttpWebResponse) httpReq.GetResponse();
}
catch(WebException ex)
{
...
}
...
I always got an WebException which says "The remote server returned an
error: (500) Internal Server Error". But actually if you open that
page in
IE, it can be opened without any problem. How can I open this page in
my
program and get the html source?
Any help would appreciate!

You don't send any HTTP header on which spaces.msn.com may rely on, like
User-Agent or Accept-Language. Try to send the same HTTP headers like a browser
(e.g. IE6) does. You can use tools like Fiddler to capture the HTTP traffic.

Cheers,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top