Avatar
← Back

Enable Error Full Messages On Published Blazor Server Website (IIS)

User Avatar
YodasMyDad 14 days ago

When publishing this blog onto IIS I was faced with the good old (Zero information) IIS error page. I knew I had .Net 8 installed and my persmissions were correct as I had a .Net 7 Blazor app running already.

I looked in event viewer in Windows and even that just said

"Failed to load coreclr. Exception message: CLR worker thread exited prematurely"

🤷‍♂️WTF...

 

FYI

It would seem this error seems to show when there is a connection issue to your database, whether wrong credentials or permissions etc... 

Something I didn't know with .Net Core. When a site is published, you do still get a web.config file! I assumed appSettings.json was the only thing it needed.

After a bit of ChatGPT'ing, I came up with these changes to the web.config to help get the real error message

<?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=".\ZauberCMS.Lee.dll" 
                  stdoutLogEnabled="true" 
                  stdoutLogFile=".\logs\stdout" 
                  hostingModel="inprocess">
        <environmentVariables>
          <environmentVariable name="ASPNETCORE_ENVIRONMENT" value="Development" />
        </environmentVariables>
      </aspNetCore>
    </system.webServer>
  </location>
</configuration>

The two main changes are adding and enabling stdlogging and changing the environment variable back to Development.

Just the environment variable change was enough for me to find the stupid error. Just putting this here as I saw a lot of posts on SO and Reddit with people getting the same error and not knowing what to do to figure it out.

© 2024 Lee - Powered By ZauberCMS