WebRequest not working

B

Bill

Can anyone tell me why the below code to downoalds a web page doesn't work
and it only downloads the below single html comment tag.
("\n\n<!-- Request Elapsed Time = 15 ms -->\n\n")?

It doesnt happen to all URLs just the one is this sample. Is there some
kind of redirect or something happend that the request is not following?

WebResponse objResponse;
WebRequest objRequest =
WebRequest.Create("http://www.bungie.net/games/halo2/page.aspx?section=FAQInfo&subsection=playlists&page=1");
objRequest.Method = "GET";
objRequest.Timeout = 120000; // 120 sec.'
objResponse = objRequest.GetResponse();
System.IO.StreamReader sr = new
StreamReader(objResponse.GetResponseStream());
string HTML = sr.ReadToEnd();
sr.Close();
 
J

Joerg Jooss

Bill said:
Can anyone tell me why the below code to downoalds a web page doesn't
work and it only downloads the below single html comment tag.
("\n\n<!-- Request Elapsed Time = 15 ms -->\n\n")?

It doesnt happen to all URLs just the one is this sample. Is there
some kind of redirect or something happend that the request is not
following?

WebResponse objResponse;
WebRequest objRequest =
WebRequest.Create("http://www.bungie.net/games/halo2/page.aspx?section
=FAQInfo&subsection=playlists&page=1"); objRequest.Method = "GET";
objRequest.Timeout = 120000; // 120 sec.'
objResponse = objRequest.GetResponse();
System.IO.StreamReader sr = new
StreamReader(objResponse.GetResponseStream());
string HTML = sr.ReadToEnd();
sr.Close();

I guess the site evaluates the User-Agent header to detect the browser
type and version. Try adding a User-Agent header string, e.g.
"Mozilla/5.0 (Windows; U; Windows NT 5.1; de-DE; rv:1.7.7)
Gecko/20050414 Firefox/1.0.3" for a German version Firefox.

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