I have an html page that I am converting over to an asp .net page. This page contained a form that accesses an external website that I have no control over. There is some sample code below:
<asp:Content ID='sample' ContentPlaceHolderID='body' Runat='Server'> <form name='Subscribe' method='post' action='http://anexternalwebsitehere.com/subscribe.asp'> <input type='text' name='email' size='45' maxlength='120' /> <input type='submit' name='submit' value='Subscribe' /> </form> </asp:Content>
The form is more complicated than the example I have provided, but it gives a rough idea of what i need to convert over. Here are the problems I have encountered.
If I leave it as is: When you click on the submit button you have a postback to the current page and not to the external page
If simply convert everything over to be asp form controls and change the postback url: The id’s become some convoluted ‘ctl00_body_ctl00’ which the external page is not able to interpret.
Note: I do need the page to be an aspx page because I am using a master page for other content on the page.
Additional note: this is not Microsoft MVC.
What am I missing?
The issue was with nested forms as others have mentioned.
I was able to fix all my issues by simply doing the following:
The old code is as follows:
The new code:
This fixes any of the issues with invalid nested forms as there are none. It also addresses the issue of asp .net renaming the asp elements because the only control that is being renamed is the asp button control which was not necessary for the submission to succeed.