top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration

Facebook Login
Site Registration

How can we detect that a MVC controller is called by POST or GET?

+3 votes
204 views
How can we detect that a MVC controller is called by POST or GET?
posted Sep 15, 2014 by Muskan

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

+2 votes
 
Best answer

When Page get loaded first time (or) Reload it will Hit GET Method. If user doing any action from Page (eg: click the submit button) it will hit the POST Method

Example:

[HttpGet]
Public ActionResult TestMethod()
{
  //This Method will Hit when Page Reload
  return view();
}

[HttpPost]
Public ActionResult TestMethod(ModelClass Model)
{
  //This Method will Hit when user click any submit button in TestMethod View
  //User did any action from Page it will Hit POST Method
  return view();
}
answer Feb 3, 2015 by Balamurugan Kn
Contact Us
+91 9880187415
sales@queryhome.net
support@queryhome.net
#280, 3rd floor, 5th Main
6th Sector, HSR Layout
Bangalore-560102
Karnataka INDIA.
QUERY HOME
...