Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

My ASP.NET Core app says it can't read web.config

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...

like image 742
ekolis Avatar asked Aug 30 '18 17:08

ekolis


People also ask

Can I use Web config in ASP.NET Core?

The web. config file has also been replaced in ASP.NET Core. Configuration itself can now be configured, as part of the application startup procedure described in Startup.

Can I use app config in .NET Core?

Application configuration in ASP.NET Core is performed using one or more configuration providers. Configuration providers read configuration data from key-value pairs using a variety of configuration sources: Settings files, such as appsettings. json.

Can asp.net application run without Web config?

yes we can run asp.net application without web. config file,if u r not configure any settings in web. config file then it will take machine.


1 Answers

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://docs.microsoft.com/en-us/aspnet/core/host-and-deploy/iis/?view=aspnetcore-2.1&tabs=aspnetcore2x

like image 80
Mehdi Ibrahim Avatar answered Oct 07 '22 09:10

Mehdi Ibrahim