0

Expected Result:

IIS hosts my app correctly, and when I navigate to the url of my app (e.g: blabla/swagger) I see the swagger UI describing my app

Problem:

When I try to navigate to my app it says:

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

Information

I built an app in .net core 2.0 and I am able to make it run through visual studio, being hosted by Kestrel. However I need to deploy this app to different servers and since Kestrel doesn't support host names, I need to make it being hosted in IIS . When I make it run through Kestrel I am able to access it correctly and by navigating to the url/swagger address, I am able to see the correct swagger page that describes the app. My app is being published from visual studio. Which means in its published folder there are all the dlls that the app needs. It's being published as a framework dependent app, not a standalone one, but this shouldn't matter.

How to replicate the problem

Since I need this one day to be hosted in IIS inside a Docker container, I am trying to make it being hosted in IIS with powershell scripts. What I did to make it being hosted in IIS is:

New-Website -Name 'myTestApp' -force -Port 8080 -PhysicalPath
'C:\Users\myUser\Desktop\Docker\PublishOutput' -ApplicationPool 'MyAppPoolTest'

Where C:\Users\myUser\Desktop\Docker\PublishOutput is the path to the published folder where Visual Studio publishes the app. Thanks in advance!

This is the web.config generated by Visual studio when publishing:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <system.webServer>
    <handlers>
      <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
    </handlers>
    <aspNetCore processPath="dotnet" arguments=".\Friss.CaseApi.Web.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" />
  </system.webServer>
</configuration>
<!--ProjectGuid: 313d542d-7676-4440-ae1b-22c6071f4309-->

And the error page is:

enter image description here

Am I setting the web.config in the wrong way?

Tarta
  • 1,729
  • 1
  • 29
  • 63
  • Possible duplicate of [IIS HTTP Error 500.19](https://stackoverflow.com/questions/11305821/iis-http-error-500-19) – CodeCaster Jun 29 '18 at 09:23
  • You've written up a nice summary, but what is missing is what you have tried to resolve the 500.19 error. Read [ask] and show your research. Most likely culprit: the application pool user has no permissions to read your private files. Publish the site somewhere else than on your desktop. – CodeCaster Jun 29 '18 at 09:24
  • @CodeCaster Already gave the access to IIS_IUSRS group to the whole published folder. In that case the "config error" would have said something about permissions – Tarta Jun 29 '18 at 09:32

2 Answers2

0

Check the documentation here

  1. You need to publish your website and then point IIS website to the published folder
  2. Application pool must be set to No Managed code
  3. Application Pool identity user IIS AppPool\{AppPoolName} must have read permissions on the published website folder
Mohsin Mehmood
  • 4,156
  • 2
  • 12
  • 18
-2

Found the solution,

the system requires the dotnet core windows hosting bundle. The bundle installs the .NET Core Runtime, .NET Core Library, and the ASP.NET Core Module.

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

Direct download to the bundle for .netcore 2.0.6 that solved my problem:https://download.microsoft.com/download/8/D/A/8DA04DA7-565B-4372-BBCE-D44C7809A467/DotNetCore.2.0.6-1-WindowsHosting.exe

Tarta
  • 1,729
  • 1
  • 29
  • 63
  • Same documentation link was provided in the answer above. – Mohsin Mehmood Jun 29 '18 at 19:15
  • @MohsinMehmood yes, which is also the first result you find on google when you find the problem. Unfortunately the point that solved my problem wasn't listed in your solution – Tarta Jun 30 '18 at 16:03