Blazor Hosted (ASP.NET) HTTP Error 500.19 - Internal Server Error
Asked Answered
E

5

6

From what I understand this error occurs when the web.config is not configured properly. However when I publish the app the following web.config gets generated

<?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=".\Lotus.Server.exe" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="inprocess" />
    </system.webServer>
  </location>
</configuration>
<!--ProjectGuid: 85a43eb6-3576-401d-b025-a15a2cc377b6-->

I first thought of installing URL Rewrite, this did not solve the problem. I am stressing out have tried almost everything any ideas on how to resolve it?

The error page looks like this:

enter image description here

Edgeways answered 13/2, 2020 at 22:0 Comment(11)
"Internal Server Error" always means: "Something happened on the server, and you have to look in the log files on the server to find out the error details". Always.Nadabus
Please post the complete error page (use screen shot if needed).Sitarski
please make sure you assigned the iis_iusrs and iusr permission to the site folder. so that it can access the Web.config file.Dimitris
@LexLi this is the complete image : ibb.co/Ld8SZByEdgeways
@UweKeim have no idea how to access the logsEdgeways
So how do you think other people her on SO can help you, if even yourself cannot get the error details on your hands?Nadabus
@UweKeim the image i posted if u search the error it says its a web.config problemEdgeways
Does this answer your question? How do I configure a .net core API to work in IIS?Sitarski
@LexLi i can run the site in the browser but not with iis ...Edgeways
"i can run the site in the browser but not with iis", You probably meant IIS Express/VS. That's because IIS Express already has ASP.NET Core module built in, while for IIS you need a separate installation.Sitarski
@LexLi no i imean IIS on windows server to host the siteEdgeways
S
8

I had this same problem and I was trying to fix it for 4 days. Then I found the solution.

Firstly you need to download dotnet hosting

https://learn.microsoft.com/en-us/aspnet/core/host-and-deploy/iis/hosting-bundle?view=aspnetcore-7.0#direct-download-current-version

Then after instalation try to restart IIS with cmd (run as admin and then write iisreset). If error page has changed we are going in good direction :)

Now it should say that you are using wrong module (which indeed is true).

Open IIS, get to your website and check installed modules. On list you should be able to see AspNetCoreModule but not AspNetCoreModuleV2.

go to: %ProgramFiles%\IIS\Asp.Net Core Module\V2
and copy aspnetcorev2.dll

Then go into %SystemRoot%\system32\inetsrv\ and paste it

Now after this, open config folder in %SystemRoot%\system32\inetsrv\ and then open applicationHost.

IMPORTANT At this stage you need to turn off your iis

Now find this line:

<add name="AspNetCoreModule" image="%SystemRoot%\system32\inetsrv\aspnetcore.dll" />

and add under it:

<add name="AspNetCoreModuleV2" image="%SystemRoot%\system32\inetsrv\aspnetcorev2.dll" />

And this same goes with this one:

<add name="AspNetCoreModule" />

add under it:

<add name="AspNetCoreModuleV2" />

Now save it, overwrite old one, and enable IIS. Go to your website, check modules and at the list you should be able to see AspNetCoreModuleV2:

[AspNetCoreModule and AspNetCoreModuleV2 on list][1] [1]: https://i.sstatic.net/jC0JC.png

Snashall answered 15/2, 2020 at 9:54 Comment(2)
Link to the latest version (6.0.7, currently) of the .NET Core hosting bundle learn.microsoft.com/en-us/aspnet/core/host-and-deploy/iis/…Taxiway
Please update the link to the more generic dotnet.microsoft.com/en-us/download/dotnet instead of the old 2.2 versionKnowledge
I
2

Fixed this by changing "AspNetCoreModuleV2" to "AspNetCoreModule" in the generated web.config in my publish folder, i.e., from

<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />

to

<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
Ilarrold answered 30/1, 2021 at 7:31 Comment(1)
I hit this issue migrating from Net7 to Net8. Couldn't understand why my Blazor site would intermittently stop working. This fixed it. Hope that helps others. Does anyone know whether this tag is needed at all in Blazor/Net8 ?Danadanae
D
1

This had me scratching my head for a while as everything was working fine on LocalHost - the error occured on the production server.

After rebuilding the site I realised that I had deleted the site folder on the production server along with its contents.

When I replaced the site I had posted it to my server node without recreating the site folder, so obviously the server couldn't access my web.config file as it was unbable to find the site folder.

Lesson learnt! Hope it saves other running down the 500.19 rabbit hole.

Danadanae answered 24/2, 2021 at 10:48 Comment(0)
E
0

At the beginning I was getting only 500 then I install all the components of IIS then I got 500.19. I installed Microsoft Rewrite Module it fixed my problem.

Elenore answered 23/7, 2024 at 23:22 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.