© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•2y ago
Brady Kelly

Minimal web API gives HTTP 500.19 error on IIS

I am trying to get a .NET 8 minimal web api up and running under IIS on Windows 11. Based on a blog post, I created a new app pool with
No managed code
No managed code
as the CLR version[1] and assigned it to the Default Web Site. Everything else is default. Then, from Rider, I use publish to folder to publish my web api project to
C:\inetpub\wwwroot
C:\inetpub\wwwroot
. When I choose
Manage website=>Browse
Manage website=>Browse
in IIS manager I get an
HTTP 500.19
HTTP 500.19
error:
The requested page cannot be accessed because the related configuration data for the page is invalid.
The requested page cannot be accessed because the related configuration data for the page is invalid.

A quick search suggested this was because my web api uses
appsettings.json
appsettings.json
, so I added a
web.config
web.config
file the project, but that made no difference. The web.config in my source is almost empty:
<?xml version="1.0" encoding="utf-8"?>

<configuration>
    <system.web>
        <compilation debug="true"  />
        <httpRuntime  />
    </system.web>
    <appSettings>
    </appSettings>
</configuration>
<?xml version="1.0" encoding="utf-8"?>

<configuration>
    <system.web>
        <compilation debug="true"  />
        <httpRuntime  />
    </system.web>
    <appSettings>
    </appSettings>
</configuration>

But after publishing it grows a little and looks like this:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <system.web>
    <compilation debug="true" />
    <httpRuntime />
  </system.web>
  <appSettings></appSettings>
  <system.webServer>
    <handlers>
      <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
    </handlers>
    <aspNetCore processPath=".\Cts.Mobile.WebApi.exe" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="inprocess" />
  </system.webServer>
</configuration>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <system.web>
    <compilation debug="true" />
    <httpRuntime />
  </system.web>
  <appSettings></appSettings>
  <system.webServer>
    <handlers>
      <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
    </handlers>
    <aspNetCore processPath=".\Cts.Mobile.WebApi.exe" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="inprocess" />
  </system.webServer>
</configuration>

Many hits on another search tell me the solution here is to remove invalid elements from the config file, but how must I know what is valid or not.
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

✅ Minimal API IIS Deployment: 404 Error
C#CC# / help
2y ago
✅ Web things minimal api
C#CC# / help
3y ago
Custom Binder Minimal API Error
C#CC# / help
8mo ago
Blazor server vs. Blazor web assembly + Minimal API
C#CC# / help
3y ago