简体   繁体   中英

Cannot insert explicit value for identity column in table

Salaamun Alekum I Am Getting NULL in file instance of action after posting a file in FORM

 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);
        }

This Is My View

@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" />
}

What Should I Do To Get Value In file Of Action Parameters. I Need Guidance On This

Thank You

The problem you have and the subject of your question are totally different. It's confusing.

If you are having an issue passing the file to your controller then your input file name should match the parameter in your controller method. Change <input type="file" name="Image" /> to <input type="file" name="file" />

Or change your action result to:

public ActionResult CreateDoctorProfile(HttpPostedFileBase Image){}

You also need to set the encryption type to your form.

using (Html.BeginForm(new { enctype = "multipart/form-data" }))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM