HttpWebRequest
-
I have a script that I can post to via a simple html form, but I can't figure out how to replicate the results with HttpWebRequest. Is there a way of getting the full functionality of a form submit via the HttpWebRequest? Works:
Does not Work: ASCIIEncoding encoder = new ASCIIEncoding(); string ifxLoc = "http://script-to-submit-to/login.dll?login"; string postData = "UserName=" + unme; postData += "&PassWord=" + upswd; byte[] data = encoder.GetBytes(postData); HttpWebRequest s2oReq = (HttpWebRequest) WebRequest.Create(ifxLoc); s2oReq.Method = "POST"; s2oReq.AllowAutoRedirect = true; s2oReq.ContentType = "application/x-www-form-urlencoded"; s2oReq.ContentLength = data.Length; Stream s2oStream = s2oReq.GetRequestStream(); s2oStream.Write(data, 0, data.Length); s2oStream.Close(); Problem: The HttpWebRequest seems to make a shallow connection to the login.dll, or doesn't fully follow through. I can't get it...working... in any way. It just returns the input of the html of the login page. Am I going about it in the wrong manner? I also need a way to impliment the native redirect that's built into the simple form submit. If I use a response.redirect() after closing the stream, it is not the same. Thanks! -Roo