2
我有这段代码;MVC5表格没有正确路由
<form action="@Url.Action("Index", "MyController")" method="post" >
<button class="btn btn-large btn-primary" id="btnNext">Click Here</button>
</form>
但按钮被点击时,它重定向到http://<domain>:2024/MyController
,我得到一个HTTP错误
405.0目录列表是不允许的。
如果我手动更改url为http://<domain>:2024/MyController/Index
我得到我的页面。
当我将表单代码更改为下面的工作。
<form action="@Url.Action("MyAction", "MyController")" method="post" >
...
索引方法声明是;
public async Task<ActionResult> Index()
{
...
}
所以这是一个不便,这是它发生的唯一的地方。我可以通过不使用索引操作来解决它,但我怎样才能跟踪并修复它?
您可以在MyController中使用HttpPost属性来共享您的Index操作的声明吗? – 2014-10-27 11:52:27
看看http://serverfault.com/a/405585/56843有帮助。 – GSerg 2014-10-27 11:53:43
@GSerg该链接是指403错误,而不是405? – DavidG 2014-10-27 11:54:43