简体   繁体   中英

How can I pass data from a form in an ASPX page to a MVC controller?

Hi have a legacy application using ASPX, I have been adding new features to it using MVC.

I'm in a situation where I have a form in the original ASPX pages and I need to do some extra work with the data provided by it. I want to send this data to a MVC controller and do the extra work there and return the results to the user with the MVC side of the application.

The ASPX pages have a SiteMaster that has a form over the entire body. The form has runat="server" set. From my limited knowledge of ASPX, I understand that I can't simply wrap the form in my own form Tag and set the action to the MVC controller. To pass the the form data I need to use a C# function that is called on click.

I have tried Response.Redirect and Server.Target but I can't figure out how to sent the form data using either of these methods.

In summary I need to send data from an ASPX form to an MVC Controller.

You can set the action of the form tag in webforms, eg

<form id="Form1" runat="server" action="/Controller/Action" >

and post whatever form data you need to your actions [HttpPost]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM