@@ -43,14 +43,14 @@ public AspNetCoreHostingEnvironment(
4343 _webHostEnvironment = webHostEnvironment ?? throw new ArgumentNullException ( nameof ( webHostEnvironment ) ) ;
4444 _urlProviderMode = _webRoutingSettings . CurrentValue . UrlProviderMode ;
4545
46- SetSiteName ( hostingSettings . CurrentValue . SiteName ) ;
46+ SetSiteNameAndDebugMode ( hostingSettings . CurrentValue ) ;
4747
4848 // We have to ensure that the OptionsMonitor is an actual options monitor since we have a hack
4949 // where we initially use an OptionsMonitorAdapter, which doesn't implement OnChange.
5050 // See summery of OptionsMonitorAdapter for more information.
5151 if ( hostingSettings is OptionsMonitor < HostingSettings > )
5252 {
53- hostingSettings . OnChange ( settings => SetSiteName ( settings . SiteName ) ) ;
53+ hostingSettings . OnChange ( settings => SetSiteNameAndDebugMode ( settings ) ) ;
5454 }
5555
5656 ApplicationPhysicalPath = webHostEnvironment . ContentRootPath ;
@@ -95,7 +95,7 @@ public string ApplicationId
9595 _hostingSettings . CurrentValue . ApplicationVirtualPath ? . EnsureStartsWith ( '/' ) ?? "/" ;
9696
9797 /// <inheritdoc />
98- public bool IsDebugMode => _hostingSettings . CurrentValue . Debug ;
98+ public bool IsDebugMode { get ; private set ; }
9999
100100 public string LocalTempPath
101101 {
@@ -188,8 +188,12 @@ public void EnsureApplicationMainUrl(Uri? currentApplicationUrl)
188188 }
189189 }
190190
191- private void SetSiteName ( string ? siteName ) =>
192- SiteName = string . IsNullOrWhiteSpace ( siteName )
191+ private void SetSiteNameAndDebugMode ( HostingSettings hostingSettings )
192+ {
193+ SiteName = string . IsNullOrWhiteSpace ( hostingSettings . SiteName )
193194 ? _webHostEnvironment . ApplicationName
194- : siteName ;
195+ : hostingSettings . SiteName ;
196+
197+ IsDebugMode = hostingSettings . Debug ;
198+ }
195199}
0 commit comments