【发布时间】:2016-10-02 06:51:24
【问题描述】:
我在通过 Ajax 调用的控制器中有一个操作方法。规范是:
[HttpPost]
public ActionResult SomeFunction(FormCollection form)
无需任何特殊的路由配置即可正常工作。
但是,如果我尝试使用模型而不是 FormCollection 作为参数,那么:
[HttpPost]
public ActionResult SomeFunction(SomeModel model)
我收到 500 错误,因为找不到该函数。
我需要在 RouteConfig 中添加什么才能使其正常工作?
【问题讨论】:
-
A
500(Internal Server Error)是因为你的方法抛出了异常(和没找到没关系) -
噢!你说得对。只是我的模型没有默认构造函数。
标签: asp.net-mvc asp.net-mvc-5 asp.net-mvc-routing model-binding