首页 新闻 会员 周边

ASP.NET Core 中默认的WebRoot是在哪里指定为的wwwroot,翻源码没找到,请告知谢谢。

0
悬赏园豆:20 [已关闭问题] 关闭于 2018-06-08 09:02

ASP.NET Core 中默认的WebRoot是在哪里指定为的wwwroot,翻源码没找到,请告知谢谢。

「圣杰」的主页 「圣杰」 | 初学一级 | 园豆:144
提问于:2018-06-08 08:32
< >
分享
所有回答(2)
0
 public static class HostingEnvironmentExtensions
    {
        public static void Initialize(this IHostingEnvironment hostingEnvironment, string contentRootPath, WebHostOptions options)
        {
            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }
            if (string.IsNullOrEmpty(contentRootPath))
            {
                throw new ArgumentException("A valid non-empty content root must be provided.", nameof(contentRootPath));
            }
            if (!Directory.Exists(contentRootPath))
            {
                throw new ArgumentException($"The content root '{contentRootPath}' does not exist.", nameof(contentRootPath));
            }

            hostingEnvironment.ApplicationName = options.ApplicationName;
            hostingEnvironment.ContentRootPath = contentRootPath;
            hostingEnvironment.ContentRootFileProvider = new PhysicalFileProvider(hostingEnvironment.ContentRootPath);

            var webRoot = options.WebRoot;
            if (webRoot == null)
            {
                // Default to /wwwroot if it exists.
                var wwwroot = Path.Combine(hostingEnvironment.ContentRootPath, "wwwroot");
                if (Directory.Exists(wwwroot))
                {
                    hostingEnvironment.WebRootPath = wwwroot;
                }
            }

.....

}
「圣杰」 | 园豆:144 (初学一级) | 2018-06-08 09:02
0
Catcher8 | 园豆:364 (菜鸟二级) | 2018-06-08 09:13
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册