views:

377

answers:

1

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.

A: 

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"&gt;
    ...
</form>

Hope this helps.

Ian Oxley
I tried this initially and the Request.Forms collection still came back empty.
JamesEggers
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