Showing posts with label is it possible to give same action method name for get and post. Show all posts
Showing posts with label is it possible to give same action method name for get and post. Show all posts

Friday, 18 August 2017

GET and POST to same Controller Action in ASP.NET MVC.



This is possible using the AcceptVerbs attribute. It’s a bit more verbose but more flexible.
[AcceptVerbs(HttpVerbs.Get|HttpVerbs.Post)]
public ActionResult Index()
{
                    // Code goes here
}