我真的很困惑,代码如下:
[HttpPost]
public ActionResult Settings(string SubmitButton)
{
if (SubmitButton == "Sign In") {
ServiceLocator.Current.GetInstance<IAppContext>().LoggedUser = null;
Response.Cookies["loginuser"].Expires = DateTime.Now;
return RedirectToAction("Logon", "Account");
}
if (SubmitButton == "Sign Up") { return RedirectToAction("register", "Account"); }
if (SubmitButton == "Change Default Ride Settings") { return RedirectToAction("changeSettings", "Home"); }
return View();
}视图包含
<% using (Html.BeginForm()) { %>
Three input ,
<% } %>控制器不是用httppost激发的,而是用httpget激发的。
发布于 2011-03-09 22:58:09
您可能需要在视图的Html.BeginForm()中传入控制器和操作名称。由于HTTP get请求调用了HttpPost Settings()操作,这意味着get请求没有另一个Settings()操作,所以我猜测您的视图是由另一个操作提供服务的。在这种情况下,您需要在Html.BeginForm()中显式设置控制器和操作。试试这个:
<% using (Html.BeginForm("Settings", "YourControllerName")) { %>发布于 2011-03-09 22:57:35
如果希望发生post,则必须生成一个html表单,并将method属性设置为post:
Html.BeginForm("action","controller", FormMethod.Post) { ... }发布于 2011-06-01 19:59:19
应该有名称索引()的操作,并且不应该包含其中的任何参数。这就是我所面对的问题。
https://stackoverflow.com/questions/5247485
复制相似问题