当我在本地计算机上运行时,以下代码可以完美运行,我设法更新了患者详细信息,但是当我将应用程序发布到IIS服务器时,却出现了错误。任何我要去哪里的建议
C#
// Edit Patient Details
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Edit(PatientDetail patientDetail,DateTime DOB)
{
if (ModelState.IsValid)
{
var currentUser = db.vwUsers.FirstOrDefault(i => i.DomainUserName == User.Identity.Name);
var apptime = DateTime.Now;
//// Save today's date.
var age = apptime.Year - DOB.Year;
//PatientDetail patientDetail = new PatientDetail();
patientDetail.Age =Convert.ToString(age);
patientDetail.LastUpdatedByUser = currentUser.FullName;
patientDetail.LastUpdatedByUserID = currentUser.AdUserName;
patientDetail.LastUpdatedOn = apptime;
db.Entry(patientDetail).State = EntityState.Modified;
db.SaveChanges();
return RedirectToAction("Edit", new { id = patientDetail.Id, updatemessage = 1 });
}
return View();
}
Chtml
@model MPFT.SendIT.Models.NewChangeIT.PatientDetail @using
(Html.BeginForm()) { @Html.AntiForgeryToken()
<div class="panel-body">
<div class="form-horizontal">
@Html.ValidationSummary(true, "", new { @class = "text-danger" }) @Html.HiddenFor(model => model.Id)
<div class="form-group">
@Html.LabelFor(model => model.Surname, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.Surname, new { htmlAttributes = new { @class = "form-control" } }) @Html.ValidationMessageFor(model => model.Surname, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.Firstname, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.Firstname, new { htmlAttributes = new { @class = "form-control" } }) @Html.ValidationMessageFor(model => model.Firstname, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.NHSNumber, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.NHSNumber, new { htmlAttributes = new { @class = "form-control" } }) @Html.ValidationMessageFor(model => model.NHSNumber, "", new { @class = "text-danger" })
</div>
</div>
</div>
}