|
-
Sep 22nd, 2006, 07:31 AM
#1
Thread Starter
Member
Handling redirects with httpwebresponse
Hi
Im writing a neat little app to fetch raw text content from a website.
However, the website im trying to get data from first sends me to a "bandwidth test site", then redirects me to the site i want data from. How can i handle this in c#?
Code so far;
VB Code:
String url = "http://www1.nrk.no/nett-tv/bokstav/@";
String content = "";
HttpWebRequest request=(HttpWebRequest)WebRequest.Create(url);
request.AllowAutoRedirect=true;
request.MaximumAutomaticRedirections=200;
HttpWebResponse request = (HttpWebResponse)myHttpWebRequest.GetResponse();
// Gets the stream associated with the response.
Stream receiveStream = request.GetResponseStream();
Encoding encode = System.Text.Encoding.GetEncoding("utf-8");
StreamReader readStream = new StreamReader( receiveStream, encode );
content = readStream.ReadToEnd();
textBox1.Text=content;
This only gets the inital page...so, how to get the redirect page?
madsun
-
Sep 22nd, 2006, 07:44 AM
#2
Thread Starter
Member
Re: Handling redirects with httpwebresponse
The request.ResponseUri.ToString(); is "http://www1.nrk.no/nett-tv/hastighet.aspx?retururl=http://www1.nrk.no/nett-tv/bokstav/@" and that takes me back to the same inital page wich im trying to avoid
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|