Fog Creek Software
Discussion Board

Welcome! and rules

Joel on Software

Making WebRequest follow redirects

I have successfully used sample code to get the html for a url:

WebRequest WReq = WebRequestFactory.Create("");
WebResponse WResp = WReq.GetResponse();
StreamReader sr = new StreamReader(WResp.GetResponseStream(), Encoding.ASCII);
// do something w/html

But what if the url issues a redirect?  How do I make my code follow the redirect?  I didn't see anything in the WebResponse documentation that looked promising.

Sunday, July 06, 2003

HttpWebRequest (which is actually what you get from WebRequest.Create with an "http" url) has an AllowAutoRedirect property (which is true by default anyway)

Duncan Smart
Monday, July 07, 2003

*  Recent Topics

*  Fog Creek Home