我有一个表单,其首页正确加载,但每当我尝试提交时,都会收到以下错误:
The resource cannot be found.
Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.
Requested URL: /Search/DoSearch
我有一个带有以下控件的 MVC 3 表单
public class HomeController : Controller
{
[HttpGet]
public ViewResult Index()
{
return View();
}
[HttpPost]
public ViewResult Index(FormModel formModel)
{
return View("Thanks", formModel);
}
}
索引页面具有以下形式
@model RequestForm.Models.FormModel
@{
Layout = null;
}
<html>
<head>
<link rel="Stylesheet" href="@Href("~/Content/Site.css")" type="text/css"/>
<title>Request page</title>
</head>
<body>
@using (Html.BeginForm("DoSearch", "Search", FormMethod.Post, new { @class = "form-class" })){
@Html.LabelFor(x => x.fullName,"Full Name")
@Html.TextBoxFor(x => x.fullName)
@Html.LabelFor(x => x.address, "Address")
@Html.TextBoxFor(x => x.address)
@Html.LabelFor(x => x.phone, "Phone Number")
@Html.TextBoxFor(x => x.phone)
@Html.LabelFor(x => x.email,"Email")
@Html.TextBoxFor(x => x.email)
<br />
<input type="submit" value="submit" />
}
</body>
</html>
我也有一个感谢查看页面
@model RequestForm.Models.FormModel
@{
Layout = null;
}
<!DOCTYPE html>
<html>
<head>
<title>Thanks</title>
</head>
<body>
<div>
Thank you for your submission
</div>
</body>
</html>
为什么没有调用感谢视图页面,为什么请求的 URL 搜索/Dosearch?