2

I have a WebAPI install on a server of mine and I keep getting the following error when browsing it:

HTTP Error 500.19 - Internal Server Error
The requested page cannot be accessed because the related configuration data for the page is invalid.

I set this up using Dot Net 5.0 WebAPI and I have it installed in the latest version of IIS after publishing to a directory.

Here's what my 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=".\akmazio-api.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="inprocess" />
    </system.webServer>
  </location>
</configuration>
<!--ProjectGuid: 3b944703-a011-4408-9581-8c919ba4ed0e-->

Any thoughts on what might be causing this issue and how to resolve it?

Adam Steinberger
  • 545
  • 1
  • 5
  • 16
  • Access the page on that server locally so that you can see the detailed error page with a 8-digit error code, like `8xxxxxxx`. That can tell you which existing discussions match the issue you met. – Lex Li Apr 21 '21 at 06:59
  • @LexLi 0x8007000d – Adam Steinberger Apr 21 '21 at 15:22
  • Does this answer your question? [asp.net core web api published in IIS after moved to different IIS server pc gives error 500.19 (0x8007000d)](https://stackoverflow.com/questions/49034308/asp-net-core-web-api-published-in-iis-after-moved-to-different-iis-server-pc-giv) – Lex Li Apr 21 '21 at 15:30
  • @LexLi see my answer here: https://stackoverflow.com/a/67202366/1694767 – Adam Steinberger Apr 21 '21 at 19:33

2 Answers2

3

Publish Core to IIS requires installation of .NET Core Hosting Bundle, for more information about it, you can refer to this link.

If you have installed the .NET Core host bundle according to the above steps, but this problem is still not resolved. I suggest you try to deploy a core template application, I suspect there may be a problem with your application.

In addition, you can also use FRT to troubleshoot this issue.

Ding Peng
  • 3,702
  • 1
  • 5
  • 8
0

It looks like the .NET Core Hosting Bundle needed to be installed, the application needed to be modified so Swagger works correctly by commenting out the env.IsDevelopment() if statement in the Startup.cs Configure() function, the following needed to be added to Startup.cs Configure() function:

            app.UseForwardedHeaders(new ForwardedHeadersOptions
            {
                ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto
            });

the public settings needed to be set to

Target location: C:\publish\directory
Delete existing files: true
Configuration: Release
Target Framework: net5.0
Target Runtime: win-x64
Deployment Mode: Self-Contained

And IIS needs to be configured so that the Application Pool has No Managed Code and runs using Network Service.

And voila I go to http://localhost/swagger/index.html and everything is now working correctly!

Adam Steinberger
  • 545
  • 1
  • 5
  • 16