What is the alternative of HttpContext.Current.Request.Files in asp .net core 5.0 mvc edit button Edit

Murugan Andezuthu Dharmaratnam | calendar 26 February 2021 | 3057

I was upgrading an asp .net MVC application to an asp .net core MVC 5.0 application. System.Web.HttpContext.Current.Request.Files was not available in asp .net core mvc 5.0 application.


You can use IFormFileCollection files = HttpContext.Request.Form.Files; insted of System.Web.HttpFileCollection files = System.Web.HttpContext.Current.Request.Files in you asp .net core 5.0 mvc application.

System.Web.HttpFileCollection files = System.Web.HttpContext.Current.Request.Files;

replace above line with

IFormFileCollection files = HttpContext.Request.Form.Files;