#411 Default webroot to wwwroot if the directory exists.
This commit is contained in:
parent
f2e7c49c36
commit
4702752384
|
|
@ -16,8 +16,27 @@ namespace Microsoft.AspNet.Hosting
|
||||||
|
|
||||||
public static void Initialize(this IHostingEnvironment hostingEnvironment, string applicationBasePath, IConfiguration config)
|
public static void Initialize(this IHostingEnvironment hostingEnvironment, string applicationBasePath, IConfiguration config)
|
||||||
{
|
{
|
||||||
var webRoot = config?[WebRootKey] ?? string.Empty;
|
var webRoot = config?[WebRootKey];
|
||||||
hostingEnvironment.WebRootPath = Path.Combine(applicationBasePath, webRoot);
|
if (webRoot == null)
|
||||||
|
{
|
||||||
|
// Default to /wwwroot if it exists.
|
||||||
|
var wwwroot = Path.Combine(applicationBasePath, "wwwroot");
|
||||||
|
if (Directory.Exists(wwwroot))
|
||||||
|
{
|
||||||
|
hostingEnvironment.WebRootPath = wwwroot;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
hostingEnvironment.WebRootPath = applicationBasePath;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
hostingEnvironment.WebRootPath = Path.Combine(applicationBasePath, webRoot);
|
||||||
|
}
|
||||||
|
|
||||||
|
hostingEnvironment.WebRootPath = Path.GetFullPath(hostingEnvironment.WebRootPath);
|
||||||
|
|
||||||
if (!Directory.Exists(hostingEnvironment.WebRootPath))
|
if (!Directory.Exists(hostingEnvironment.WebRootPath))
|
||||||
{
|
{
|
||||||
Directory.CreateDirectory(hostingEnvironment.WebRootPath);
|
Directory.CreateDirectory(hostingEnvironment.WebRootPath);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue