We do have App_Data
in vNext.
This should still work
string path = AppDomain.CurrentDomain.GetData("DataDirectory").ToString();
As for Server.MapPath
equivalents you can use AppDomain.CurrentDomain.BaseDirectory
and build your path from there.
You can also use the IApplicationEnvironment
service
private readonly IApplicationEnvironment _appEnvironment;
public HomeController(IApplicationEnvironment appEnvironment)
{
_appEnvironment = appEnvironment;
}
public IActionResult Index()
{
var rootPath = _appEnvironment.ApplicationBasePath;
return View();
}
IHostingEnvironment
is the moral equivalent of the IApplicationEnvironment
for web applications. For PhysicalFileSystem, IHostingEnvironment
falls back to IApplicationEnvironment
.
private readonly IHostingEnvironment _hostingEnvironment;
public HomeController(IHostingEnvironment hostingEnvironment)
{
_hostingEnvironment = hostingEnvironment;
}
public IActionResult Index()
{
var rootPath = _hostingEnvironment.MapPath("APP_DATA");
return View();
}