无法在 table 中为标识列插入显式值
Cannot insert explicit value for identity column in table
萨拉蒙阿勒库姆
在 FORM
中发布文件后,我在 file
操作实例中得到 NULL
public ActionResult CreateDoctorProfile(HttpPostedFileBase file)
{
int LoggedInPersonID = Convert.ToInt32(Session["LoggedInPersonId"]);
erx_t_personnel PersonnelInformation = db.erx_t_personnel.Where(PersonnelInformation1 => PersonnelInformation1.Person_Id == LoggedInPersonID).FirstOrDefault();
return View(PersonnelInformation);
}
这是我的观点
@model Doctors_Search_Engine.Models.erx_t_personnel
@{
ViewBag.Title = "Personnel Registration";
}
<h2>Personnel Registration</h2>
@using (Html.BeginForm())
{
@Html.AntiForgeryToken()
<input type="file" name="file" />
<input type="submit" value="Create" class="btn btn-default" />
}
我应该怎么做才能在 file
操作参数中获得价值。我需要这方面的指导
谢谢
你遇到的问题和你提问的主题完全不一样。令人困惑。
如果您在将文件传递给控制器时遇到问题,那么您的输入文件名应与控制器方法中的参数相匹配。
更改 <input type="file" name="Image" /> to <input type="file" name="file" />
或者将您的操作结果更改为:
public ActionResult CreateDoctorProfile(HttpPostedFileBase Image){}
您还需要为您的表单设置加密类型。
using (Html.BeginForm(new { enctype = "multipart/form-data" }))
萨拉蒙阿勒库姆 在 FORM
中发布文件后,我在file
操作实例中得到 NULL
public ActionResult CreateDoctorProfile(HttpPostedFileBase file)
{
int LoggedInPersonID = Convert.ToInt32(Session["LoggedInPersonId"]);
erx_t_personnel PersonnelInformation = db.erx_t_personnel.Where(PersonnelInformation1 => PersonnelInformation1.Person_Id == LoggedInPersonID).FirstOrDefault();
return View(PersonnelInformation);
}
这是我的观点
@model Doctors_Search_Engine.Models.erx_t_personnel
@{
ViewBag.Title = "Personnel Registration";
}
<h2>Personnel Registration</h2>
@using (Html.BeginForm())
{
@Html.AntiForgeryToken()
<input type="file" name="file" />
<input type="submit" value="Create" class="btn btn-default" />
}
我应该怎么做才能在 file
操作参数中获得价值。我需要这方面的指导
谢谢
你遇到的问题和你提问的主题完全不一样。令人困惑。
如果您在将文件传递给控制器时遇到问题,那么您的输入文件名应与控制器方法中的参数相匹配。
更改 <input type="file" name="Image" /> to <input type="file" name="file" />
或者将您的操作结果更改为:
public ActionResult CreateDoctorProfile(HttpPostedFileBase Image){}
您还需要为您的表单设置加密类型。
using (Html.BeginForm(new { enctype = "multipart/form-data" }))