in MVC Language by
How Can We Restrict Mvc Actions To Be Invoked Only By Get Or Post?

▼ Show 1 Answer

0 votes
We can decorate the MVC action by “HttpGet” or “HttpPost” attribute to restrict the type of HTTP calls. For instanceyou can see in the below code

snippet the “DisplayCustomer” action can only be invoked by “HttpGet”. If we try tomake Http post on “DisplayCustomer” it will throw an error.


public ViewResult DisplayCustomer(int id)


Customer objCustomer = Customers[id];

return View("DisplayCustomer",objCustomer);

Learn More with Madanswer

Related questions

0 votes
asked Aug 18, 2019 in MVC Language by sheetalkhandelwal