I have Web Api developed using .NET Core 2.0 working onsite on Windows2022 server with IIS10 and AspNetCore 2.2 Hosting bundle installed. Recently client has uninstalled this hosting bundle due to .Net Core 2.2 End Of Life support and wants to use .NET8. I have installed .NET8 Runtime and Hosting bundle. Now Api is not working. I have also created new .NET 8 version of this Api but that also is not working. Below is the Api Web Config file used for both Api versions.
Error1 when I click Web Site->IIS Authentication or Configuration Editor-> There was an error while performing operation.
Error2 when I run Api and browse URL-> HTTP Error 500.19 - Internal Server Error The requested page cannot be accessed because the related configuration data for the page is invalid.
When I delete complete <system.webServer> section, Error1 is gone but browsing URL gives error HTTP Error 503. The service is unavailable.
Errors in Event Viewer - None
Q: Does .NET 8 Hosting Bundle contain AspNetCoreModuleV2 equivalent? Is there any other hosting module name I should use? How do I resolve this issue? Web Config
ASP.NET Core Hosting Bundle contains everything you need to run existing web/ server apps. The bundle includes the .NET runtime, the ASP.NET Core runtime, and if installed on a machine with IIS it will also add the ASP.NET Core IIS Module.
In some cases, reinstalling the ASP.NET Core module may resolve the issue. You can do this by repairing or reinstalling the .NET Hosting Bundle. I suggest you reinstall the hosting package, it might fix the problem.
ASP.NET Core 8.0 Runtime (v8.0.0) - Windows Hosting Bundle Installer download link: https://dotnet.microsoft.com/en-us/download/dotnet/8.0
Once you've installed the hosting bundle, the AspNetCoreModule is available in the IIS native module list.

Make sure your application pool is configured to use the correct .NET CLR version. For .NET 8, this should be set to ".NET CLR Version" -> "No Managed Code".

If you've checked all of these areas and the problem persists, you may want to consider reviewing the specific error message in the detailed error page. When you receive a 500.19 error, more information is usually available on the detailed error page.
Update1:
You may need to verify that the path to the dotnet executable exists in the deployment machine's environment variables. To check this, first find the path where dotnet.exe is installed. It is generally located in either C:\Program Files\dotnet or C:\Program Files (x86)\dotnet. Once you know the path, ensure that the path exists in your Environment Variables.
Control Panel > System > Advanced System Settings > Environment Variables. highlight "Path", click 'Edit' and verify that the path to the dotnet folder is present. If it isn't, add it. Do the same for both the User variables and System variables. Restart your machine and try again.
The AspNetCoreModule is configured via the web.config file found in the application's root, which points a the startup command (dotnet) and argument (your application's main dll) which are used to launch the .NET Core application. The configuration in the web.config file points the module at your application's root folder and the startup DLL that needs to be launched.
For example, here's what the web.config looks like:
<?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=".\MyApp.dll"
stdoutLogEnabled="false"
stdoutLogFile=".\logs\stdout"
hostingModel="inprocess" />
</system.webServer>
</location>
</configuration>
You can see that module references dotnetexe and the compiled entry point DLL that holds your Main method in your .NET Core application.
For more info, please refer this link: Configuration of ASP.NET Core Module with web.config.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With