I referred this, which suggests that I can use IHttpContextAccessor
to access HttpContext.Current
. But I want to specifically receive files which that object doesn't seem to have.
So is there any alternative for Httpcontext.Current.Request.Files
in Asp.Net Core 2.0
Inside controller context and in action you can access files via HttpContext.Request.Form.Files
:
public IActionResult Index()
{
var files = HttpContext.Request.Form.Files;
return View();
}
and outside controller you have to inject IHttpContextAccessor
.
for upload file read File uploads in ASP.NET Core.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With