Passing Image to Controller ASP.NET MVC

前端 未结 1 373
心在旅途
心在旅途 2021-01-16 05:30

I am trying to send Image and ImageName from View to Controller.

Here\'s how my controller looks:

  [HttpPost]
  public ActionResult Add(BoxAddViewMo         


        
相关标签:
1条回答
  • 2021-01-16 06:15

    Your using the wrong overload of BeginForm() and adding route values, not html attributes (always inspect the html your generating). Use

    @using (Html.BeginForm("Add", "BoxManagement", FormMethod.Post, new { @class = "form-horizontal", enctype = "multipart/form-data" }))
    

    Side note: Remove new { @name = "Name"} from your TextBoxFor() method. Never attempt to override the name attribute generated by the HtmlHelper methods unless you want binding to fail (and is this case it does nothing anyway)

    0 讨论(0)
提交回复
热议问题