In ASP.NET MVC 1 you had to check the Request.Files property when you want to upload one or more files from your web application.
1: public class HomeController : Controller
2: {3: public ActionResult ProcessFiles()
4: {5: foreach (string file in Request.Files)
6: {7: //Process files
8: }9: return View();
10: } 11: }As this is not directly helping to make a testable controller action, they were some initiatives to make this testable.
In ASP.NET MVC 2 you get by default a ModelBinder that extracts the files from the Request and assign it to a parameter of your controller action method.
1: public class HomeController : Controller
2: {3: public ActionResult ProcessFiles(IEnumerable<HttpPostedFileBase> files)
4: {5: foreach (var file in files)
6: {7: //Process files
8: }9: return View();
10: } 11: }Beautiful isn’t it?