0

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.

JamesEggers
  • 12,885
  • 14
  • 59
  • 86

1 Answers1

0

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.

Ian Oxley
  • 10,916
  • 6
  • 42
  • 49
  • I tried this initially and the Request.Forms collection still came back empty. – JamesEggers Jul 27 '09 at 14:13
  • Might be worth tracking the request at the HTTP level to see exactly what is being sent in the POST data - tools such as Firebug's Net panel or a proxy server such as the one that comes with Burp Suite (http://www.portswigger.net/suite/) should help with this. – Ian Oxley Aug 04 '09 at 12:36