c# - 在 Controller 上找不到操作方法

标签 c# asp.net-mvc

尽管有很多与此类似的问题,但似乎没有一个相关,所以

我有这个签名的 Action

[HttpPost]
public ActionResult SaveOrder(PizzaOrder pizza, Guid? id){
    ...
}

我正在尝试提交一个带有按钮的表单。我已验证该按钮向

发送了一个 POST
https://my/controller/url/SaveOrder?id=...

PizzaOrder 数据似乎也被正确发布。

但是,我的 Action 永远不会被击中。相反,MVC 抛出异常

A public action method 'SaveOrder' was not found on controller
'Controllers.PizzaController'.

为什么?

最佳答案

POST 不会在 URL 查询字符串中发送表单数据。

关于c# - 在 Controller 上找不到操作方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17495701/

相关文章:

c# - 通过单击 ListView (Xamarin.Forms) 中的按钮获取当前项

c# - 如何防止 .NET 库在关闭时发送 RST 数据包

c# - 使用 C# 4 创建 PDF 文件?

asp.net-mvc - 我的自定义 Controller 中的 Null ControllerContext 继承自 BaseController

c# - 接收错误 "The type or namespace name ' LayoutsPageBase' 找不到”

c# - 使用 as 运算符进行转换,即使在使用 is 运算符验证 C# 中的类类型之后?

asp.net-mvc - 如何在 asp.net mvc 中使用 SOAP

asp.net - ASP MVC : Can I drop a client connection programatically?

asp.net-mvc - ASP.NET MVC 的插件架构

asp.net-mvc - Pro ASP.net MVC框架代码问题