How do I configure a .net core API to work in IIS?

落花浮王杯 提交于 2020-03-30 02:01:35

问题


I've got a .net core API created in Visual Studio 2017 that's working fine. When I go to deploy it I get error message HTTP Error 500.19 with error code 0x8007000d. I've found multiple solutions online such as making sure windows features are installed, removing the .net CLR version, changing the application pool identity, changes to web.config and applicationHost.config, but nothing has worked. Is there a way to definitively find what the problem is or am I stuck doing trial and error with the myriad of possible solutions? Any specific solutions you know of?

Here are screenshots of the IIS settings and my Windows features:

Here's my web.config file:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <!--
    Configure your application settings in appsettings.json. Learn more at     http://go.microsoft.com/fwlink/?LinkId=786380
  -->
  <system.webServer>
    <handlers>
      <add name="aspNetCore" path="*" verb="*"
        modules="AspNetCoreModule" resourceType="Unspecified" />
    </handlers>
    <aspNetCore processPath="dotnet"
                arguments=".\DishbooksAPI.dll" 
                stdoutLogEnabled="false" 
                stdoutLogFile=".\logs\stdout" 
                forwardWindowsAuthToken="false" />
  </system.webServer>
</configuration>

Here's the IIS error:

Some stackoverflow pages I've tried (this is not an exhaustive list):

HTTP Error 500.19 when publish .net core project into iis

HTTP Error 500.19 with Error Code 0x8007000d visual studio 2017 while deploying .net core application

ASP.NET: HTTP Error 500.19 – Internal Server Error 0x8007000d

HTTP Error 500.19 - Internal Server Error web config .net core web api

asp.net core web api published in IIS after moved to different IIS server pc gives error 500.19


回答1:


First of all, you need to install ASP.NET Core Module in web server. Here is the download link.

Then install either SDK or Runtime in web server.

Trouble Shooting

If it still doesn't work, open a command prompt. Navigate to the web application folder and type dotnet YOUR_APP.dll. You should see something like this -

C:\APIs> dotnet YOUR_APP.dll
Hosting environment: Production
Content root path: C:\APIs
Now listening on: http://localhost:5000
Application started: Press Ctrl+C to shut down.

It means your application can run in the web server without IIS. Then you need to trouble shoot in IIS or some other things.




回答2:


You would need the hosting bundle to be installed on IIS

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

Steps :

  1. click the preferred version
  2. Search for 'Hosting Bundle' word (should be on the right side)
  3. Install the same
  4. re-start IIS. And validate your site and see the magic

Why Hosting bundle is needed? Check following article https://dotnetcoretutorials.com/2019/12/23/hosting-an-asp-net-core-web-application-in-iis/

How to check if hosting is installed? How to determine if asp.net core has been installed on a windows server



来源:https://stackoverflow.com/questions/50612351/how-do-i-configure-a-net-core-api-to-work-in-iis

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!