How can we restrict MVC actions to be invoked only by GET or POST?

Total Post:135

Points:949

 3298  View(s)
Ratings:
Rate this:
Hi All,
How can we restrict MVC actions to be invoked only by GET or POST? Please give me a solution.

thanx.
  1. Re: How can we restrict MVC actions to be invoked only by GET or POST?

    I have got it, its answer. Details explanation is below:
    We can restrict the MVC action with the HttpGet or HttpPost attribute to restrict the type of HTTP calls. For example,In below code DisplayStudent action can only be invoked by HttpGet. If we try to make HTTP POST on DisplayStudent, it will throw an error.


    [HttpGet]
    public ViewResult DisplayStudent(int id)
    {
        Student objStudent = Studentss[id];
        return View("DisplayStudent",objStudent);

      Modified On Feb-14-2016 11:02:28 PM

Answer

Please check, If you want to make this post sponsored

You are not a Sponsored Member. Click Here to Subscribe the Membership.