[英]Cannot insert explicit value for identity column in table
Salaamun Alekum我在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" }))
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.