尝试在我的网页上发布部分视图表单时出现以下错误:
类型' System.Web.HttpException'的例外情况发生在System.Web.dll中但未在用户代码中处理
其他信息:执行处理程序的子请求时出错' System.Web.Mvc.HttpHandlerUtil + ServerExecuteHttpHandlerAsyncWrapper'。
错误与主视图中的以下行相关
主视图是:
@{
ViewBag.Title = "Home Page";
}
<div class="jumbotron">
@Html.ActionLink("Create a Club", "SelectClubType", "Club")
</div>
<div>
@Html.Action("SelectClubType", "Club")
</div>
<div class="row">
<p>something here</p>
</div>
部分视图是:
@model GRCWebApp.ViewModels.SelectClubTypeViewModel
@{
Layout = null;
}
@using (Html.BeginForm())
{
@Html.AntiForgeryToken()
<div class="form-group">
<div class="row col-md-12">
<h3>Create a new Club - Select the type</h3>
</div>
<div class="row col-md-12">
<div class="col-md-3">
@Html.DropDownListFor(model => model.SelectedClubTypeId, new SelectList(Model.ClubTypes, "ClubTypeId", "ClubTypeName"), new { @class = "form-control" })
</div>
<div class="col-md-2 ">
<input type="submit" value="Create" class="btn btn-success" />
</div>
</div>
</div>
}
后方法:
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult SelectClubType(SelectClubTypeViewModel model)
{
int id = model.SelectedClubTypeId;
return RedirectToAction("Create", new { id = id });
}