C# 试图在数据库中发布数据,但我得到的是空字段

C# 试图在数据库中发布数据,但我得到的是空字段,c#,asp.net,.net,asp.net-mvc,asp.net-mvc-5,C#,Asp.net,.net,Asp.net Mvc,Asp.net Mvc 5,嘿,我有一个模式弹出表单,我必须上传文件并将数据发布到数据库。当我按下submit键时,我的RedirectToAction方法出现错误,似乎找不到action Dokument。当我检查文档数据库中字段的值时,我看到的都是空值。Im使用位数组上传文件。 这是我的密码: 控制器 public ActionResult Dokument() { return View(); } public ActionResult GetTipi() {

嘿,我有一个模式弹出表单,我必须上传文件并将数据发布到数据库。当我按下submit键时,我的RedirectToAction方法出现错误,似乎找不到action Dokument。当我检查文档数据库中字段的值时,我看到的都是空值。Im使用位数组上传文件。 这是我的密码:

控制器

public ActionResult Dokument()
    {
        return View();
    }

    public ActionResult GetTipi()
    {
        Test_kristiEntities1 db = new Test_kristiEntities1();
        return Json(db.AAC_procedure_document_types.Select(x => new
        {
            Id_Tipi = x.Id_Tipi,
            Emri_llojit = x.Emri_llojit
        }).ToList(), JsonRequestBehavior.AllowGet);
    }


    // Bind(Include = "Nr_Kutise, Rafti, Zyra,")]NgarkoDokument ngarkoDok

    [HttpPost]
    [ValidateAntiForgeryToken]
    public ActionResult Create(HttpPostedFileBase upload, AAC_procedure_document_types model,NgarkoDokument ngarkoDok,AAC_procedure_documents dokumente)
    {
        try
        {
            if (ModelState.IsValid)
            {
                if (upload != null && upload.ContentLength > 0)
                {
                    var file = new AAC_procedure_documents
                    {
                        Emer_Dokumenti = System.IO.Path.GetFileName(upload.FileName),
                        //FileType = FileType.Avatar,
                        Content_Type = upload.ContentType
                    };
                    using (var reader = new System.IO.BinaryReader(upload.InputStream))
                    {
                        file.Permbajtje_Dokumenti = reader.ReadBytes(upload.ContentLength);
                    }
                    ngarkoDok.AAC_procedure_documents = new List<AAC_procedure_documents> { file };
                }

                ViewData["Rafti"] = dokumente.Rafti;
                ViewData["Zyra"] = dokumente.Zyra;
                ViewData["Nr_Kutise"] = dokumente.Nr_Kutise;

               // lokacion.Rafti = formCollection["Rafti"].ToString();
               // lokacion.Zyra = formCollection["Zyra"].ToString();
               // lokacion.Nr_Kutise = Convert.ToInt32(formCollection["Nr_Kutise"]);

                db.AAC_procedure_documents.Add(dokumente);
                db.SaveChanges();
                return RedirectToAction("Dokument");
            }
        }
        catch (RetryLimitExceededException /* dex */)
        {
            //Log the error (uncomment dex variable name and add a line here to write a log.
            ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists see your system administrator.");
        }
        return View(dokumente);
    }
<div id="myModal" class="modal fade" role="dialog">
    <div class="modal-dialog">

<!-- Modal content-->
<div class="modal-content">
    <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">&times;</button>
        <h4 class="modal-title">Ngarkoni dokumenta</h4>
    </div>
    <div class="modal-body">
        @using (Html.BeginForm("Create", "NgarkoDokument", FormMethod.Post, new { enctype = "mulptiple/form-data" }))
        {
            @Html.AntiForgeryToken()

            <div class="form-group">
                <label for="exampleFormControlSelect1">Lloji i dokumentit</label><br />
                <select title="Lloji i dokumentit" name="lloji" class="form-control col-md-3 box" id="tipiDropdown"> </select>


                <input type="button" title="Ngarko dokument" name="ngarko" value="Ngarko" id="uploadPop" class="btn btn-info col-md-3" onclick="document.getElementById('file').click();" />
                <input type="file" onchange="javascript: updateList()" multiple="multiple" style="display:none;" id="file" name="postedFiles" />
                <div id="fileList"></div>
            </div>
            <br /><br />

            <div class="form-group">
                <label for="formGroupExampleInput">Fusha indeksimi</label> <br />
                @*<input title="Indeksimi dokumentit" id="indeksimi" class="form-control col-md-3" type="text" name="indeksimi" placeholder="indeksimi" required />*@
                @Html.TextBoxFor(a => a.Fusha_Indeksimit.Emri_Indeksimit, new { @class = "form-control", @placeholder = "indeksimi" })

                <button title="Shto indeksim" id="modalPlus" type="submit" class="btn btn-info"><i class="glyphicon glyphicon-plus"></i></button>


            </div>

            <label for="formGroupExampleInput">Vendndodhja fizike e dokumentit</label><br>
            <div id="zyraModal" class="form-group col-md-4">
                @*<input title="Zyra fizike" id="zyra" class="form-control" type="text" name="zyra" placeholder="Zyra" />*@
                @Html.TextBoxFor(a => a.Vendndodhja_fizike.Zyra, new { @class = "form-control", @placeholder = "Zyra" })
            </div>

            <div class="form-group col-md-4">
                @* <input title="Kutia fizike" id="kutia" class="form-control" type="number" name="kutia" placeholder="Nr i kutisë" />*@
                @Html.TextBoxFor(a => a.Vendndodhja_fizike.Nr_Kutise, new { @class = "form-control", @placeholder = "Nr i kutisë" })
            </div>

            <div class="form-group col-md-4">
                @* <input title="Rafti fizik" id="rafti" class="form-control" type="text" name="rafti" placeholder="Rafti" />*@
                @Html.TextBoxFor(a => a.Vendndodhja_fizike.Rafti, new { @class = "form-control", @placeholder = "Rafti" })
            </div>

            <br /><br />

            <div class="row" id="ruaj">
                <button value="Create" title="Ruaj dokumentin" type="submit" class="btn btn-success">Ruaj</button>
            </div>
        }
    </div>
</div>
public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            routes.MapRoute(
                name: "Default",
                url: "{controller}/{action}/{id}",
                defaults: new { controller = "Home", action = "Login", id = UrlParameter.Optional }
            );