我正在使用ASP.NET MVC,我正在尝试使用IOS7和Safari浏览器使我的Web项目在IPad下工作。
我的问题仅在IPAD下,当我在IE9-10 Chrome或Firefox下进行测试时,一切正常: 在向服务器提交表单后,我返回一个新表单。 当我想发布我的新表单时,我的ViewModel和FormCollection是空的。
奇怪的部分开始:如果我刷新当前页面或按safari上的后退按钮,我的帖子工作并填充ViewModel(和FormCollection)。
这是我的代码:
客户代码:
@using (Html.BeginForm("AnswerFeedback", "Customer", FormMethod.Post, new { id = "QuestionForm" }))
{
@Html.HiddenFor(model => model.IDQuizz)
@Html.HiddenFor(model => model.IDFeedbackReporting)
@Html.HiddenFor(model => model.ActualQuestion.Type)
@Html.HiddenFor(model => model.ActualQuestion.ID)
....
<div class="row">
<div class="col-md-4 col-md-offset-4 col-xs-4 col-xs-offset-4 text-center">
<input type="submit" id="saveCustomerFeedBack" class="btn btn-primary btn-large btn-block" value="@Html.TextLocalized(2031, "Next", (int)Model.IDLangue)" />
</div>
</div>
}
服务器代码:
[HttpPost]
public ActionResult AnswerFeedback(QuizzFeedbackViewModel viewModel)
{
// my viewModel contains null fields and formCollection is empty
FormCollection formCollection = new FormCollection(this.HttpContext.Request.Form);
int? nextQuestionID = ValidateQuestion(viewModel);
if (nextQuestionID == null)
return RedirectToAction("FeedBackDone", new { IDFeedBackReporting = viewModel.IDFeedbackReporting });
return RedirectToAction("AnswerFeedback", new { IDFeedBackReporting = viewModel.IDFeedbackReporting, nextQuestionID = nextQuestionID, viewModel.QuizzName });
}