Skip to content

Instantly share code, notes, and snippets.

@corespider
Created June 22, 2021 04:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save corespider/ddf16ac9663e2a06828275f7cb0fbd15 to your computer and use it in GitHub Desktop.
Save corespider/ddf16ac9663e2a06828275f7cb0fbd15 to your computer and use it in GitHub Desktop.
Server.MapPath not working in ASP.Net Core
public class HomeController : Controller
{
private IHostingEnvironment Environment;
public HomeController(IHostingEnvironment _environment)
{
Environment = _environment;
}
public IActionResult Index()
{
string wwwPath = this.Environment.WebRootPath;
string contentPath = this.Environment.ContentRootPath;
return View();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment