server.mappath equivalent in asp.net core code example
Example: core 5 Server.MapPath
public class HomeController : Controller
{
private readonly IHostingEnvironment _hostingEnvironment;
public HomeController(IHostingEnvironment hostingEnvironment)
{
_hostingEnvironment = hostingEnvironment;
}
public ActionResult Index()
{
return Content($"WebRootPath = {_hostingEnvironment.WebRootPath}\n" +
$"ContentRootPath = {_hostingEnvironment.ContentRootPath}");
}
}