复现步骤如下:
- Open VS2017
- Create a new
ASP.NET Core Web Application (.NET Core)
Choose the "Web API" template and target "ASP.NET Core 1.1" (no authentication)
Your
Main
looks like this now:public static void Main(string[] args) { var host = new WebHostBuilder() .UseKestrel() .UseContentRoot(Directory.GetCurrentDirectory()) .UseIISIntegration() .UseStartup<Startup>() .UseApplicationInsights() .Build(); host.Run(); }
Your csproj looks like this:
<Project Sdk="Microsoft.NET.Sdk.Web"> <PropertyGroup> <TargetFramework>netcoreapp1.1</TargetFramework> </PropertyGroup> <ItemGroup> <Folder Include="wwwroot\" /> </ItemGroup> <ItemGroup> <PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.0.0" /> <PackageReference Include="Microsoft.AspNetCore" Version="1.1.2" /> <PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.1.3" /> <PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="1.1.2" /> </ItemGroup> <ItemGroup> <DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="1.0.1" /> </ItemGroup> </Project>
Hit F5 to run and
localhost:6565/api/values
open up- Add a "Web Configuration File" to the root of the project
Uncomment the
system.webServer
section looking like this:<system.webServer> <handlers> <remove name="aspNetCore"/> <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified"/> </handlers> <aspNetCore processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" /> </system.webServer>
Open the IIS Manager GUI
- Choose "Add Website", pick a name and a port, set the path to the folder where the
web.config
is located - As per Microsoft's instructions set the Application Pool's ".NET CLR version" to "No Managed Code"
Browse to your new application, e.g.
http://localhost:8089/api/values
Result: HTTP Error 502.5 - Process Failure
Expected: same result as in step 4.
- 将应用程序池的标识设置为
LocalSystem
- 在控制台上检查是否可以运行
dotnet --version
(即是否在PATH上可用)
此外,我还尝试了其他一些方法:
- 将
processPath
设置为"%LAUNCHER_PATH%\bin\Debug\netcoreapp1.1\WebApplication1.dll
的变体 - 将
processPath
指向dotnet.exe
或其位置 - 重新阅读文档以找出一种方法来解决这个问题。
对于基于.NET Framework的ASP.NET MVC应用程序,您可以在完整的IIS中启动一个指向MVC项目文件夹的新网站,它会“自动工作”。
你需要做什么才能使它与ASP.NET Core一起工作?即使没有发布,也有可能使此流程工作吗?