Not to be confused with cross page posting, cross domain submission allows us to post the contents of an ASP.NET form to a completely different domain.
We will cover two cases. The first is pretty easy. You just need a form on your screen that will allow you to send the information to another domain. The second will be more complex. You need a form on your screen that you fill from your domain prior to sending to the second domain.
To start, create a new ASPX page. You can use a master page if you want. It won’t make much difference.
Because ASP.NET has it’s own FORM tags, to add another form tag into the output, you’ll want to close off the current form tag and start another. The best way to do this is with a literal control. This way the ASP.NET runtime engine will not be confused and any of the other runat=server controls you have on the page after this new form will continue to behave as expected. However, you’ll want to make sure that any controls that produce input tags of their own all appear prior to the new form tag.
<%-- It is best if all your pages controls exist prior to the new form here --%> <asp:Literal ID="Literal1" runat="server" Text= '</form><form name="subform" action="newDomainAndPage" method="POST">' ></asp:Literal> <input type="text" name="someName" /> <input type="submit" name="submit" value="Submit" />
The submit button will now post to the site specified in “newDomainAndPage”
- 12 November 2009 at 8:11am
- Dew Drop – November 12, 2009 | Alvin Ashcraft's Morning Dew
[...] ASP.NET Cross Domain Form Submission (Dave M. Bush) ...