Server is currently not available under the new HttpContext but there are two ways to get the traditional MapPath results.
- You can use the extension method MapPath for the IHostingEnvironment interface.
- You can retrieve the path from the IApplicationEnvironment instance.
Both of these are easily accessible via constructor injection, by placing them in the HomeController constructor as shown below you can easily extract the path you are looking for.
var wwwRoot = server.MapPath("web.config");
var webConfig = new FileInfo(wwwRoot);
var isWebConfig = webConfig.Exists;
var svrPath = server.MapPath("Views/Home")
var isDirSvr = Directory.Exists(svrPath);
var envPath = appEnv.ApplicationBasePath
var isDirEnv = Directory.Exists(envPath);