你如何找到用于访问你的应用程序的http动词(POST,GET,DELETE,PUT)?我看httpcontext.current但似乎有任何属性给我信息.谢谢
Dan*_*ite 41
使用HttpContext.Current.Request.HttpMethod.
请参阅:http://msdn.microsoft.com/en-us/library/system.web.httprequest.httpmethod.aspx
在 ASP.NET CORE 2.0 中,您可以使用以下命令获取(或设置)当前上下文的 HTTP 谓词:
Request.HttpContext.Request.Method
Run Code Online (Sandbox Code Playgroud)
小智 5
if (HttpContext.Request.HttpMethod == HttpMethod.Post.Method)
{
// The action is a post
}
if (HttpContext.Request.HttpMethod == HttpMethod.put.Method)
{
// The action is a put
}
if (HttpContext.Request.HttpMethod == HttpMethod.DELETE.Method)
{
// The action is a DELETE
}
if (HttpContext.Request.HttpMethod == HttpMethod.Get.Method)
{
// The action is a Get
}
Run Code Online (Sandbox Code Playgroud)