0

If you want to send an object of type HttpPostedFile to an action, you may get null object in the action. So how to send it?

halfer
  • 19,824
  • 17
  • 99
  • 186
Mohsen Abasi
  • 2,050
  • 28
  • 30

1 Answers1

-1

To do this, you may need send HttpPostedFile via Temp Data. For a sample, see the following:

HttpPostedFileBase file;
TempData["FilePosted"] = file;

And in the action, do this:

HttpPostedFileBase file = (HttpPostedFileBase)TempData["FilePosted"];
halfer
  • 19,824
  • 17
  • 99
  • 186
Mohsen Abasi
  • 2,050
  • 28
  • 30
  • 1
    Hi there. Please refrain from adding "be a Muslim to success" and "in the name of Allah" to your questions and answers. I have edited this from your material before, and I'd wouldn't like to think you are giving me work to do deliberately. – halfer Dec 29 '16 at 21:52