lundi 30 novembre 2015

dont call Action Post in mvc when use enctype

In my project I have View Like this :

@using (Html.BeginForm(MVC.Admin.Sys.ActionNames.Index, MVC.Admin.Sys.Name, FormMethod.Post, new { enctype = "multipart/form-data" }))
{...}

And My actions Are :

 [HttpGet]
    public virtual ActionResult Index()
    {...}
[HttpPost]
public virtual ActionResult Index(EditSysInfo sysInfoViewModel,HttpPostedFileBase file)
    {}

in View I have :

 <input type="file" name="file"/> ... submit button

but when Click On the submit button dont cann Post action , and redirect to httpget Action . yesterday its work fine . I dont know why doesnt run ? Today I just Install Microsoft.AspNet.Web.Optimization . when Change to this :

@using (Html.BeginForm())

Its work fine , but cant post file to action this way .

I try to getting file in Action Like This :

HttpPostedFileBase logo = Request.Files.Get("file");

Allways Count Request.Files is Zero.

thanks .

Aucun commentaire:

Enregistrer un commentaire