How can be detect that an mvc controller is callled by POST or GET

To detect if the call on the controller is a POST action or a GET action we can use the Request.HttpMethodproperty as shown in the below code snippet.

public  ActionResult SomeAction()
{    
if(Request.HttpMethod == "POST"
)
    {

return View("SomePage");
    }    
else
    {      
return View("SomeOtherPage");
    }
}

results matching ""

    No results matching ""