asp.net-mvc - C# ASP.NET MVC : Find out whether GET or POST was invoked on controller action

标签 asp.net-mvc

如何确定 GET 还是 POST 命中了我的 ASP.NET MVC Controller 操作?

最佳答案

您可以查看 Request.HttpMethod为了那个原因。

if (Request.HttpMethod == "POST") {
    //the controller was hit with POST
}
else {
    //etc.
}

关于asp.net-mvc - C# ASP.NET MVC : Find out whether GET or POST was invoked on controller action,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1169490/

相关文章:

由于在发送到服务器之前添加了 URL,AJAX 请求无效

jquery - 将大型 JSON 对象发布到 ASP.NET MVC

javascript - 将 View 中的 javascript 数据发送到 mvc 中的函数

html - ASP.NET MVC 动态表单

asp.net-mvc - 允许 EmailAddressAttribute 为空字符串

asp.net-mvc - 从数据库更新模型时出现 System.ArgumentException

c# - 基于一组关键字进行搜索

asp.net - 混合 ASP.NET/ASP.NET MVC 应用程序中的 Index.aspx

asp.net-mvc - 自定义 HtmlHelper 扩展方法在 View 中不可用?

c# - User.IsInRole() 在 MVC C# 类中工作