问题
I have 2 ASP.Net applications in a solution. One is pretty much a testing harness for a 3rd party app that POSTs data into the primary application. I tried to mimic this functionality by doing a basic HTML form and setting the action to point to the main application; however, the Request.Form NameValueCollection was empty. I tried doing it in ASP.Net using a 307 redirect and I had the same issue. I temporarily have moved the temp form into the main project so I can continue testing.
Here is the 307 Redirect code that I was using:
Response.ClearContent();
Response.StatusCode = 307;
Response.StatusDescription = "Temporary Redirect";
//redirect to a different app.
Response.RedirectLocation = "http://localhost:xxxx/default.aspx";
Response.Flush();
Is there a way to do cross domain POSTing in ASP.net web forms? It works in the same domain but not different domains for some reason.
回答1:
The easiest way would be to use a non-server-side <form> i.e. with no runat="server" attribute, and just set the action attribute to the URL you want to post to:
<form method="post" action="http://localhost:xxxx/default.aspx">
...
</form>
Hope this helps.
来源:https://stackoverflow.com/questions/1188266/cross-domain-posting-in-asp-net-loses-form-fields