在我之前的问题之后,现在事情不再起作用了,这里是:
我在 MVC 4 中有表单,但表单按钮没有响应:
控制器(应该得到 post 操作):
public class GeneralController {
[HttpPost]
public ActionResult SearchResults(SearchParamsModel searchParams)
{
// doin some stuff here
return View("SearchResultsView");
}
}
查看(.cshtml):
@model MVC.Models.SearchParamsModel
@{
ViewBag.Title = "SomeTitle";
}
@Html.Partial("~/Views/SomePartials/ssi-header.cshtml");
@Html.Partial("~/Views/SomePartials/ssi-sidebar-notifications.cshtml");
<!-- content -->
<section class="content right">
<section class="some-search">
<div class="form-separator gradient"></div>
@using (Html.BeginForm("SearchResults", "Home", FormMethod.Post))
{
<section class="form-field">
<input type="text" name="City" id="City" class="field field139 autocomplete-init-no-img" />
<label for="City">City</label>
</section>
<input type="submit" value="Submit Search" class="submit btn blue-btn special-submit" />
}
</section>
</section>
<!-- end content -->
@Html.Partial("~/Views/SomePartials/ssi-footer.cshtml");
模型 :
public class SearchParamsModel
{
public string City{ get; set; }
}
事情只有在我添加 View 时才有效:Layout = null
(!!!Wierd)
我的布局
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>@ViewBag.Title - My ASP.NET MVC Application</title>
<link href="~/favicon.ico" rel="shortcut icon" type="image/x-icon" />
<meta name="viewport" content="width=device-width" />
@Styles.Render("~/Content/SomeStyles")
@*@Scripts.Render("~/bundles/SomeScripts")*@
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script src="../../Scripts/script1.js" type="text/javascript"></script>
<script src="../../Scripts/script2.js"></script>
....
</head>
<body>
<div id="body">
@RenderSection("featured", required: false)
<section class="content-wrapper main-content clear-fix">
@RenderBody()
</section>
</div>
@*@RenderSection("scripts", required: false)*@
</body>
</html>