Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I check if a controller was called using post or get?

Tags:

In ASP.Net MVC, how can I check in a controller method, if it was called using post or get?

I am aware I can limit methods to being called only by post or by get - but how can I check for post/get in a method that allows both?

like image 445
Kjensen Avatar asked Nov 15 '09 16:11

Kjensen


2 Answers

ControllerContext.HttpContext.Request.HttpMethod

or just

Request.HttpMethod 

in Controller

like image 197
LukLed Avatar answered Jan 18 '23 23:01

LukLed


You can check the Request.HttpMethod property.

like image 34
Darin Dimitrov Avatar answered Jan 18 '23 22:01

Darin Dimitrov