This is regarding forwarding POST variables properly in ASP.Net
To force all connections use the https protocol rather than http, I inserted the following code in Global.asax
If Not Request.IsSecureConnection Then
Response.Redirect("https://" & Request.ServerVariables("HTTP_HOST") + Request.RawUrl)
End If
This was working fine until I encountered a form which is submitted using POST, and using the above method is breaking the form retrieval process.
Eg: the webpage is http://abc.com/page1.aspx (this page accepts only POST form data). now with forcing the application to redirect to https, the page is correctly getting redirected to https://abc.com/page1.aspx, however, all the form data is lost in the process.
Is there a way I can store and forward the Request.Form data??
That’s pretty much what the HTTP 307 status code is for. You may want to consider redirecting them with an HTTP 307 status instead of 302.
An HTTP 307 means redirect, and re-submit POSTed data:
There is no super easy way to do it in ASP.NET, but it isn’t hard either. For example:
Alternatively, you could use
Server.Transfer(string)as well. Phil Haack gives an explanation of that here. That may be a simpler option for you.