私の以前の質問に続いて、物事が再び機能しなくなりました。
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; }
}
ビューに追加した場合にのみ機能します: 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>