1
votes

Code:

webRequest = WebRequest.Create("https://---.com/bbb.aspx") as HttpWebRequest;
            webRequest.Method = "POST";
            webRequest.ContentType = "application/x-www-form-urlencoded";
            webRequest.CookieContainer = cookies;
            webRequest.KeepAlive = true;
            webRequest.Proxy = new WebProxy("127.0.0.1:8888");
            webRequest.UserAgent = "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1847.116 Safari/537.36";
            webRequest.Referer = "https://---.com/bbb.aspx";
            webRequest.MaximumAutomaticRedirections = 1;
            webRequest.AllowAutoRedirect = true;
            webRequest.ServicePoint.SetTcpKeepAlive(true, 15, 200);
            webRequest.ServicePoint.UseNagleAlgorithm = false;
            webRequest.ServicePoint.Expect100Continue = false;

its redirected to ccc.aspx..the http header (Fiddler) is

POST https://---.com/bbb.aspx HTTP/1.1
Content-Type: application/x-www-form-urlencoded
User-Agent: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko)       Chrome/34.0.1847.116 Safari/537.36
Referer: https://---.com/bbb.aspx
Host: ---.com
Cookie: ASP.NET_SessionId=************; skysales=**********
Content-Length: 1753

and it's successful direct to ccc.aspx, but why the content type header is application/x-www-form-urlencoded too, in fiddler, it's GET request, not POST

GET https://---.com/ccc.aspx HTTP/1.1
Content-Type: application/x-www-form-urlencoded
User-Agent: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko)    Chrome/34.0.1847.116 Safari/537.36
Host: ---.com
Cookie: ASP.NET_SessionId=*********; skysales=********
1
HTTP redirects always use GET. - SLaks
yes, but why content type in fiddler show Content-Type: application/x-www-form-urlencoded when GET?? @SLaks - Igi Shellshock
That sounds like a bug in HttpWebRequest. - SLaks

1 Answers

0
votes

This is a bug in HttpWebRequest, on this line of code.

When handling redirect responses, they correctly reset the method, but do not remove related headers.