3

We have a dotnet core 3.1 web API application that is published to an IIS 10 hosted on a Windows 2012 R2 datacenter VM.

The application is running under an application pool that has no managed code:

app pool screenshot

IIS is not able to read the web.config. This is what I get when clicking this app's Connection Strings in IIS:

IIS error

web.config

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <security>
            <authorization>
                <remove users="" roles="mydomain\mydevrole" verbs="" />
                <add accessType="Allow" users="?" roles="" />
            </authorization>
        </security>
    </system.webServer>
</configuration>
joym8
  • 4,014
  • 3
  • 50
  • 93
  • Common if you forgot to install some IIS OOB components. Check https://docs.jexusmanager.com/tutorials/oob-500.html#oob-related-500-19-errors – Lex Li Apr 27 '20 at 21:03
  • On Windows 10, this did not install properly. It appeared on Start menu after installation completed, but clicking it brought up "Choose an application to open..." – joym8 Apr 27 '20 at 22:13
  • Installing Jexus Manager is optional. You should focus on your web.config file and see if you forgot any OOB used inside. – Lex Li Apr 27 '20 at 22:43
  • Most settings are in the appsettings.json. The only thing in web.config is an authorization section. And I know authorization feature exists on that VM and working because other framework apps that rely on it are working fine. – joym8 Apr 27 '20 at 23:58

2 Answers2

6

Installing ASP.NET Core Runtime is not enough. You have to install the Hosting Bundle.

https://dotnet.microsoft.com/download/dotnet-core/3.1

download page

joym8
  • 4,014
  • 3
  • 50
  • 93
  • This is a life saving answer. THANK YOU! – Sarahbe Dec 06 '22 at 08:04
  • I searched for the cause for a long time and found none. Especially since I did not get a concrete error code, but only a message saying that something was wrong. But just not concretely what! Your post has led me ultimately to the solution! I installed this whole environment that you linked here and restarted the server. After that the problem was finally fixed! Thanks a lot for that! – peter70 Jan 25 '23 at 08:58
0

Have you checked file permissions? Specifically has the IIS_IUSR$ group got permissions to read the folder where the website is located? Also check the windows event logs to see if there is more information.

  • Try an empty web.config file from https://support.microsoft.com/en-gb/help/815179/how-to-create-the-web-config-file-for-an-asp-net-application – timhowarduk Apr 28 '20 at 08:25
  • Also try renaming file, and see if IIS creates one (been a while, can't remember if it does this or not) – timhowarduk Apr 28 '20 at 08:29
  • Also, not sure if this is relevant, as I've not used dot net Core myself yet. https://learn.microsoft.com/en-us/aspnet/core/migration/configuration?view=aspnetcore-3.1 Quotes: "ASP.NET Core no longer uses the Global.asax and web.config files that previous versions of ASP.NET utilized." "The web.config file has also been replaced in ASP.NET Core" – timhowarduk Apr 28 '20 at 08:33
  • Renaming web.config helped. No new web.config was created automatically. IIS is now opening the features/properties for this app. But doing this has rendered the app useless. API routes are not working. Only static HTML/CSS files are working. Basically IIS is just acting as a web server. – joym8 Apr 28 '20 at 11:28