如何使用post或get检查控制器是否被调用?

Kje*_*sen 17 asp.net-mvc controller

在ASP.Net MVC中,如何使用post或get调用控制器方法?

我知道我可以限制只通过post或get来调用方法 - 但是如何检查post/get in允许两者的方法呢?

Luk*_*Led 34

ControllerContext.HttpContext.Request.HttpMethod
Run Code Online (Sandbox Code Playgroud)

要不就

Request.HttpMethod 
Run Code Online (Sandbox Code Playgroud)

在控制器中


Dar*_*rov 11

您可以检查Request.HttpMethod属性.