我有这样的控制器:如何将文件传递给控制器
public ActionResult Index(HttpPostedFileBase file)
{
if (file != null && file.ContentLength > 0)
try
{
string path = Path.Combine(Server.MapPath("~/Files"),
Path.GetFileName(file.FileName));
file.SaveAs(path);
ViewBag.Message = "Success";
}
catch (Exception ex)
{
ViewBag.Message = "Error:" + ex.Message.ToString();
}
return RedirectToAction("NewController", new { myFile : file });
}
我的新控制器:
public ActionResult NewController(HttpPostedFile myFile)
{
}
我想“文件”传递给NewController
但它给了我一个错误在RedirectToAction
。我如何将正确的值传递给RedirectToAction
以便它能正常工作?谢谢。
什么是错误 –