天天看點

ASP.NET CORE API 部署到IIS 上HTTP錯誤 500.19-Internal Server Error 錯誤代碼:0x8007000d

今天在部署一個asp.net core api時候,出現的一個問題,主要原因還是自己對core 應用部署不是太清楚導緻的,這裡把問題描述一下,然後把如何asp.net core api部署到iis的步驟記錄一下。

問題:

部署完成以後,一直提示

HTTP錯誤 500.19-Internal Server Error 錯誤代碼:0x8007000d

分析原因;

這是一個.net core 的api,我已經安裝了aspnetcore-runtime, 想當然的以為就可以通路者api了。 最後找到原因是過程中少了DotNetCore.2.0.0-WindowsHosting.exe. 安裝這個之後,成功調用api。那麼這個東西到底是啥鬼呢。

 .NET Core Windows Server 托管捆綁包建立 IIS 與 Kestrel 伺服器之間的反向代理。ASP.netCore使用的是自托管web伺服器Kestrel。 是以IIS隻是一個代理作用。

正确在iis部署asp.net core 應用的步驟:

  1. 添加IIS
  2. ASP.NET CORE RUNTIME
  3. DotNetCore.2.0.0-WindowsHosting.exe

編譯程式過程;

  1. pushd D:\tool

    nuget.exe restore "D:\zzzzzzzzzzzzzzzzzzr.API.sln" -ConfigFile "C:\Users\Administrator\AppData\Roaming\NuGet\NuGet.Config" -NoCache

  2. pushd C:\Program Files\dotnet

    dotnet publish -c release -o "C:\jxxxxng" "D:\xxxyyyketing.Api.csproj"

新問題:

Application 'MACHINE/WEBROOT/APPHOST/TESTJIEBAOMARKETINGAPI' with physical root 'C:\inetpub\xxxxxxt\Api\' failed to start process with commandline 'dotnet .\xxxxx.Api.dll', ErrorCode = '0x80004005 : 80008096.

找到原因。在指令行下面運作

C:\inetpub\JiebaoMarketingTest\Api>dotnet Jxxxxg.Api.dll
It was not possible to find any compatible framework version
The specified framework 'Microsoft.AspNetCore.App', version '2.1.1' was not foun
d.
  - Check application dependencies and target a framework version installed at:
      C:\Program Files\dotnet\
  - Installing .NET Core prerequisites might help resolve this problem:
      https://go.microsoft.com/fwlink/?LinkID=798306&clcid=0x409
  - The .NET Core framework and SDK can be installed from:
      https://aka.ms/dotnet-download
  - The following versions are installed:
      2.1.0-rc1-final at [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.Ap
p]
           

在環境下安裝相應的asp.net core framework就可以了