Search code examples
c#.net-2.0webrequest

Webrequest Disallow AutoRedirect


In .Net 2.0 how can I disallow AutoRedirect when using WebRequest? I found some source code were there where used an AllowAutoRedirect property, but on my WebRequest there is no such property.


Solution

  • You need to cast it to a HttpWebRequest

    HttpWebRequest WebRequest =
    (HttpWebRequest)System.Net.WebRequest.Create("http://www.mySite.com");
    WebRequest.AllowAutoRedirect = false;