The underlying connection was closed: An unexpecte
I am trying to post login credentials to a web page using __viewstate and my credentials for login. Here is what I do -
1. Request for the sign on page.
2. Receive the response
3. Extract the viewstate out.
4. Attach my credentials.
5. Post a new request for login.
6. Receive the response.
The program fails at step 6 and I receive the error "The underlying connection was closed: An unexpected error occurred on a receive.". I caught the WebException and it gives me no further details just that it shows the status of the exception as "ReceiveFailure". I tried somethings like
a) Set KeepAlive = false.
b) Set AutoRedirects = true.
but it didn't work.
For testing purpose - I copied the viewstate that I extracted, put the credentials as hidden field and submitted the form as plain html and I was able to login. That just means that there is something that I am not doing right, or .Net is not allowing me to do correctly. (I am using .Net 1.1)
The stack trace is as follows -
at System.Net.HttpWebRequest.CheckFinalStatus() at System.Net.HttpWebRequest.EndGetResponse(IAsyncRes ult asyncResult) at System.Net.HttpWebRequest.GetResponse() at WebLoginCheck.WebForm1.Page_Load(Object sender, EventArgs e) in c:\inetpub\wwwroot\weblogincheck\webform1.aspx.cs: line 78
Can somebody give me an insight on origin of the problem and what could be the possible causes. I will appreciate your inputs.