Someone, please help - struggled with this lousy problem!
What I do - I have an ASPX page from which I create a GET, and then POST to an HTTPS page to enter it. I spent a lot of time comparing my GET and POST constructs with the GET / POST browser using a violinist (protocol analyzer) and my requests are fine.
However, when I try to log into the browser, everything works fine and it logs in. When I start my page, I can see the correct GET and POST, but I get the 302 "moved object" error found
Initially, I thought it was a cookie problem, but after many experiments I am sure that this has nothing to do with cookies. I turned off cookies and javascript in the browser and tried, and the pages worked fine without them. Then I simulated the exact GET / POST.
This is my situation:
- My GET and GET Browsers EXACTLY VERY
- The 200 OK response from the site is EXACTLY the same EXCEPT for three VIEWSTATE variables that have slightly different lengths (why? Why different, even if the GET is the same?)
- POST POST and POST browsers EXACTLY EXCLUDE 3 ViewState variables (I correctly populate them from GET)
- And yet the browser is logging in while I get a detected 302 detected / moved error message.
A few other things -
a) I copied the POST response from a recent POST browser and replaced the POST settings with this POST browser and got the correct answer! That means - my headlines are just good
- my encoding setting / environment, etc. - something suspicious of VIEWSTATE values, which can only be because the browser sent it to me first (there is no distortion when parsing GET VIEWSTATE variables and using it in POST, this is completely normal)
update I also tried WebClient just to check - it makes no difference, the same 302. update The moved object basically points to the error page that says: “a serious blah blah error occurred” - POST causes an error on the server, and ONLY the difference between a good POST (browser), and my POST are Viewstate variables.
So - WHAT AM I WRONG? Why is this cruel world tormenting me ?! !!
(PS is another difference in the browser sequence, I don’t know how important this is)
Browser:
CONNECT
GET
GET (for a favicon, which returns an error)
CONNECT
POST (success)
Me:
CONNECT
GET
POST (flaming failure, 302 - page moved)
and for those who care, my POST header build code
HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create(URL); myRequest.UserAgent = chromeUserAgent; //myRequest.CookieContainer = cCookies; myRequest.ContentType = "application/x-www-form-urlencoded"; myRequest.Accept = chromeAccept; myRequest.Referer = url; myRequest.AllowAutoRedirect = false; myRequest.Host = "thesitethatskillingme.com"; myRequest.Headers.Add("Origin", "https://thesitethatskillingme.com"); myRequest.Headers.Add("Accept-Encoding", chromeAcceptEncoding); myRequest.Headers.Add("Accept-Language", chromeAcceptLanguage); myRequest.Headers.Add("Accept-Charset", chromeAcceptCharset); myRequest.Headers.Add("Cache-Control", "max-age=0"); myRequest.ServicePoint.Expect100Continue = false; myRequest.Method = "POST"; myRequest.KeepAlive = true; ASCIIEncoding ascii = new ASCIIEncoding(); byte[] bData = ascii.GetBytes(data); myRequest.ContentLength = bData.Length; using (Stream oStream = myRequest.GetRequestStream()) oStream.Write(bData, 0, bData.Length);
... and then read the stream, etc. cookie