2

I have an ASP.NET Blazor web site, using .NET7 running on Windows Server 2022/IIS 10.

Due to some problems I'm having with uploads, I decided to try enabling shadow copy, as this is supposed to avoid this problem.

I followed the info on this blog post, and changed my Web.config file to look like this...

<?xml version="1.0"
      encoding="utf-8"?>

<configuration> <location path="." inheritInChildApplications="false"> <system.webServer> <handlers> <add name="aspNetCore" path="" verb="" modules="AspNetCoreModuleV2" resourceType="Unspecified" /> </handlers> <aspNetCore processPath="dotnet" arguments=".\MyWebSite.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="inprocess"> <handlerSettings> <handlerSetting name="enableShadowCopy" value="true" /> <handlerSetting name="shadowCopyDirectory" value="../_ShadowCopyDirectory/" /> </handlerSettings> </aspNetCore> </system.webServer> </location> </configuration>

However, this results in the web site not starting, and a 500 being returned. If I comment out or remove the <handlerSettings> section, the site works fine.

Looking in the server event log shows an entry with a source of IIS AspNetCore Module V2 and the following description...

Could not load configuration. Exception message:

That's it, the total message.

It looks to me as if IIS isn't managing to read the config file, which would usually be because the XML is invalid, but I've checked it in a validator, and came out OK.

Although I don't think it's getting that far, the _ShadowCopyDirectory folder exists, so that's not the problem. I've enabled parent paths, so that shouldn't be it either, although as I said, my suspicion is that it's not even getting that far.

The site in question is using .NET 7, which supports this feature, so that shouldn't be the issue either. I checked the IIS logs, but they don't show anything for the times it failed to load.

Anyone any idea what might be going wrong, or where I might look for more information? The event log was no help.

2 Answers2

0

I had the same issue, fixed by deleting web.config and re-uploading. Simply overwriting it didn't help.

Max Toro
  • 221
0

Make sure that you have the latest version of the ANCM and the Windows Hosting Bundle installed. The setting was enabled using that name only after .NET 7.0 RTM - prior to that only the preview names worked and if those names are not supported that's when web.config errors would come up.

Also make sure that you're app has rights to read in the Web folder. That's hard to do, but could happen if you used a custom account that doesn't have at least Read access in your Web root.

Application Pool and ASP.NET Runtime startup errors usually show up in the Event Log, so look there for additional information on the error that's occurring.