15

I get this error when I access my app which I published to local IIS:

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

My web.config is really simple:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <location path="." inheritInChildApplications="false">
    <system.webServer>
      <handlers>
        <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
      </handlers>
      <aspNetCore processPath="dotnet" arguments=".\TreesOnMars.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" />
    </system.webServer>
  </location>
</configuration>
<!--ProjectGuid: 14bfa9ba-0bd6-4ae2-a6f4-6e3e91d35263-->

What could be wrong? I tried giving all users permission to read my c:\inetpub\wwwroot folder... the web.config doesn't have any obvious error in it! I tried some of the solutions at this question but they didn't work...

ekolis
  • 6,270
  • 12
  • 50
  • 101
  • 1
    Why do you have the element on there? Did you add that yourself? Did you look in the server's event logs to see if there's any more information? – mason Aug 30 '18 at 17:23
  • 2
    Is it core ? Core has json file – khaled Dehia Aug 30 '18 at 18:01
  • 1
    Yes, it is Core. It runs just fine in Visual Studio with a web.config; how would I create a JSON file for use with IIS? – ekolis Aug 30 '18 at 18:20
  • 3
    I didn't add a `` element; this is the default config generated by Visual Studio. – ekolis Aug 30 '18 at 18:21
  • I don't see anything in `eventvwr` related to my app running on IIS; there are a few entries for errors running in Visual Studio, though. – ekolis Aug 30 '18 at 18:25
  • 3
    The error page should contain a line number. What's that then? If it is 0, then you forget to install the server bundle (which contains ASP.NET Core Module). – Lex Li Aug 30 '18 at 19:05
  • I don't see any line number listed; however under "Config source" I see two numbers: -1 and 0. – ekolis Aug 31 '18 at 01:26
  • Add app.UseDeveloperExceptionPage(); in your startup.cs and show us what the error page looks like. – Mehdi Ibrahim Aug 31 '18 at 05:30

1 Answers1

29

You need to install the .NET Core hosting bundle to host .NET Core apps in IIS. The bundle installs the .NET Core Runtime, .NET Core Library, and the ASP.NET Core Module. The link to the .NET Core 2.1 hosting bundle is here: https://www.microsoft.com/net/download/thank-you/dotnet-runtime-2.1.3-windows-hosting-bundle-installer

Also make sure the following Windows features are enabled:

enter image description here

More information can be found here:

https://learn.microsoft.com/en-us/aspnet/core/host-and-deploy/iis/?view=aspnetcore-2.1&tabs=aspnetcore2x

Mehdi Ibrahim
  • 2,434
  • 1
  • 13
  • 13