ASP.net web form - post data to a controller in an MVC site
This may be a stupid question, but anyway... I have an MVC site and a legacy ASP.net web forms site. I have a controller action on my MVC site that I would like to (programatically) POST to from my web forms site.
I can find lots of information describing RESTful services etc., but I can't seem to find a resource that exp开发者_如何学JAVAlains how to do this bit - anybody point me in the right direction?
In MVC, there is nothing special about the FORM
on the page (unlike WebForms).
Just create a normal HTML FORM
(without runat="server"
). Set the action
to point to your controller action. Set the method
to POST
.
That's it. In your controller action, you can access the FormCollection
directly, or you can attempt to use parameter/model binding.
This post demonstrates how to post data to web server with HttpWebRequest. You just need to compose your own data to be posted, and change the url that the data will be posted to. It's the url of your controller in your case.
精彩评论