I faced the following error while using the RedirectToAction
method in ASP.NET MVC 5.
[HttpPost]
public ActionResult UploadOrderReport(HttpPostedFileBase file)
{
string targetFolder = HttpContext.Server.MapPath("~/Reports");
string targetPath = Path.Combine(targetFolder, file.FileName);
file.SaveAs(targetPath);
var currentReports = Directory.GetFiles(targetFolder).ToList();
return RedirectToAction("CurrentProfile", new { existReport = new List<string>(currentFiles)});
}
However, in my CurrentProfile
method I got unexpected data
[HttpGet]
public ActionResult Index(List<string> existReports)
and debugger shows that existsReports
argument is System.Collections.Generic.List``1[System.String]
I suppose my problem related to type casting?