我在调用控制器功能时遇到了一个小问题。奇怪的是,其他所有提交按钮都可以正常工作。但是这个有我现在无法解决的问题。我将向您展示两个带有提交按钮的表单,因为只有一个可以正常工作。
控制器:
public class MyController : Controller
{
public ActionResult MethodOne()
{
...
return RedirectToAction("index");
}
public ActionResult MethodTwo()
{
...
return RedirectToAction("index");
}
}
和观点:
//This one works fine!!
@using (Html.BeginForm("MethodOne", "My", FormMethod.Post))
{
<input id="Some-cool-id" type="submit" value="Add!" />
}
//This one doesn't work?!
@using (Html.BeginForm("MethodTwo", "My", FormMethod.Post))
{
<input id="some-cool-id2" type="submit" value="Delete"!" />
}
错误告诉 Method2 不在所需的路径中。
Resource not found.
Description: HTTP 404. Searched resource (or ...) ...
Required path URL: /My/MethodTwo
我一直在寻找不好的地方,但最后,我需要帮助,谢谢。