如何将HttpPostedFile发送到某个控制器中的操作

时间:2016-12-27 11:15:52

标签: model-view-controller httppostedfilebase httppostedfile

如果要将HttpPostedFile类型的对象发送到某个操作,则可能会在操作中获得null对象。那么如何发送呢?

1 个答案:

答案 0 :(得分:-1)

为此,您可能需要通过Temp Data发送HttpPostedFile。有关示例,请参阅以下内容:

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

在行动中,这样做:

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