Skip to content

Instantly share code, notes, and snippets.

@natemcmaster
Created June 18, 2016 22:55
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 natemcmaster/8f2cb9fbfddcdedcd379b15060cc44e8 to your computer and use it in GitHub Desktop.
Save natemcmaster/8f2cb9fbfddcdedcd379b15060cc44e8 to your computer and use it in GitHub Desktop.
ASP.NET Core Directories

Development-time

src/
  Web/  <-- Microsoft.AspNetCore.Hosting.IHostingEnvironment.ContentRootPath, System.IO.Directory.GetCurrentDirectory()

    project.json
    web.config
    
    wwwroot/ <--  Microsoft.AspNetCore.Hosting.IHostingEnvironment.WebRootPath
      app.js
    
    Views/Home/
      Index.cshtml
      
    bin/Debug/netcoreapp1.0/
      Web.dll <-- System.AppContext.BaseDirectory

Publish time

C:\inetpub\  <-- System.AppContext.BaseDirectory, Microsoft.AspNetCore.Hosting.IHostingEnvironment.ContentRootPath, System.IO.Directory.GetCurrentDirectory()
  Web.dll
  web.config
  
  wwwroot/   <-- Microsoft.AspNetCore.Hosting.IHostingEnvironment.WebRootPath
      app.js
    
  Views/Home/
    Index.cshtml

Why not set ContentRootPath = Directory.GetCurrentDirectory()?

Because current directory is settable by anything within the process. It is not guaranteed that a user service won't change this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment