You could write a custom web client and enable this functionality:
public class WebClientEx : WebClient
{
protected override WebRequest GetWebRequest(Uri address)
{
var request = (HttpWebRequest)base.GetWebRequest(address);
request.AllowAutoRedirect = false;
return request;
}
}
and then:
using (var client = new WebClientEx())
{
Console.WriteLine(client.DownloadString("http://google.com"));
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…