c# - AspNet MVC - return RedirectToAction is not working with image upload (if file.SaveAs gets called) -


return redirecttoaction not working if imageupload.saveas(path); executed otherwise working (i mean if not select image not reach line imageupload.saveas(path);).

here code:

[httppost]     public actionresult createnewemployee(employee emplview, httppostedfilebase imageupload)     {         if (!modelstate.isvalid)         {             var mod = new personaldetailsviewmodel(emplview);             return view("addemployee", mod);         }         if (imageupload != null && imageupload.contentlength > 0)         {             var filename = emplview.employeeid + "_" + path.getfilename(imageupload.filename);             var path = path.combine(server.mappath("~/content/images/"), filename);              imageupload.saveas(path);             emplview.photograph = filename;         }         _dbcontext.employees.add(emplview);         _dbcontext.savechanges();          return redirecttoaction("personaldetails", new { id = emplview.employeeid });     } 

i checked debugger, reaching last line , executing not redirecting action method. don't know doing wrong?

i checked within following method of global.asax hidden error, there wasn't any:

protected void application_error(object sender, eventargs e)     {         exception ex = server.getlasterror();     } 

perhaps move your: imageupload.saveas(path); async method allowing rest of code execute without waiting image upload process finish. suspecting getting collusion image upload request while trying give response controller.


Comments

Popular posts from this blog

ios - MKAnnotationView layer is not of expected type: MKLayer -

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -