我有一个具有多个选项卡的应用程序来提交表单。但是,用户在单击“提交”后将获得一个空白表格,并且不会重定向到确认页面。这很奇怪,因为有些应用程序提交得很好,而另一些应用程序没有将字段中的数据存储到数据库中。我的第一个猜测是这是防火墙问题。我正在使用发布方式提交。另外请注意,这是在生产服务器上发生的,而不是在本地开发环境上发生的。
控制器:
[HttpPost]
[ValidateAntiForgeryToken]
[Authorize(Roles = "Applicant")]
public IactionResult Application(ApplicationViewModel model)
{
var saved = false;
model = _applicantManager.RebuildApplicationViewModel(model);
if (ModelState.IsValid)
{
saved = _applicantManager.SubmitApplication(model,CurrentUser.username);
return RedirectToaction("Index");
}
return View(model);
}
表格(相当大,为简单起见已缩短):
@Html.ValidationSummary(excludePropertyErrors: false,message: "",htmlAttributes: new { @style = "color:red" })
<ul class="wdn_tabs">
<li><a href="#personalTab" class="inactiveLink">Personal</a></li>
<li><a href="#academicTab" class="inactiveLink">Academic</a></li>
<li><a href="#questionsTab" class="inactiveLink">Questions</a></li>
<li><a href="#availabilityTab" class="inactiveLink">Availability & Reference</a></li>
</ul>
@using (html.beginform(actionName: "Application",controllerName: "Applicant",method: FormMethod.Post))
{
@Html.AntiForgeryToken()
<div class="wdn_tabs_content">
<div id="personalTab">
<h4>Personal Information</h4>
<div style="color:red"><strong>All fields are required.</strong></div>
<div class="tabBody">
<div class="inputGroup spacer">
<strong>@Html.DisplayNameFor(x => x.PersonalInfo.FirstName)</strong>
@Html.ValidationmessageFor(x => x.PersonalInfo.FirstName)
@Html.TextBoxFor(x => x.PersonalInfo.FirstName)
</div>
<div class="inputGroup spacer">
<strong>@Html.DisplayNameFor(x => x.PersonalInfo.LastName)</strong>
@Html.ValidationmessageFor(x => x.PersonalInfo.LastName)
<input type="text" asp-for="PersonalInfo.LastName" />
</div>
..........................other fields..........................
</div>
<div class="tabFooter">
<a href="#questionsTab" class="wdn-button wdn-button-brand">Back</a>
<button type="submit" class="wdn-button wdn-button-complement">Submit</button>
</div>
</div>
</div>
}