编辑1 :我使用相同的配置遇到了与ASP NET Core 2.0应用程序相同的问题,因此本身排除了框架。下一个潜在的罪魁祸首: .NET Core 2.1 SDK(v2.1.300)或一个糟糕的Visual Studio更新(15.7.3)。
我调试API时,IIS 10和ASP NET Core 2.1.0存在一个奇怪的问题。
我有一个IIS网站" api.local "使用ASP NET Core 2.0应用程序" v1 "在里面。
" v1"应用程序配置为使用" api.local"我创建网站时生成的应用程序池。此应用程序池配置如下:
为了在Visual Studio 2017(15.7.3)中进行调试,我使用以下launchSettings.json
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iis": {
"applicationUrl": "https://api.local/v1",
"sslPort": 0
}
},
"profiles": {
"IIS": {
"commandName": "IIS",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"launchBrowser": true,
"launchUrl": "graphiql/"
}
}
}
一切正常。
现在,每次开始调试时,都会创建一个新的IIS应用程序池,称为" v1 AppPool" (然后" v1 AppPool 2"等等)和" v1"网站配置更改以使用此新创建的IIS Applicataion池。
我不知道从什么时候开始,但我认为在将以下nuget软件包更新到2.1.0版本之后就开始了:
<PackageReference Include="Microsoft.AspNetCore.Authorization" Version="2.1.0" />
<PackageReference Include="Microsoft.AspNetCore.Diagnostics" Version="2.1.0" />
<PackageReference Include="Microsoft.AspNetCore.Localization" Version="2.1.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.1.0" />
<PackageReference Include="Microsoft.AspNetCore.Server.IISIntegration" Version="2.1.0" />
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel" Version="2.1.0" />
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel.Https" Version="2.1.0" />
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="2.1.0" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="2.1.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.AzureKeyVault" Version="2.1.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="2.1.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Configuration" Version="2.1.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="2.1.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="2.1.0" />
<PackageReference Include="Newtonsoft.Json" Version="11.0.2" />
供参考,这是我的WebHostBuilder初始化:
public static IWebHost BuildWebHost(string[] args) =>
new WebHostBuilder()
.UseKestrel()
.UseContentRoot(Directory.GetCurrentDirectory())
.ConfigureLogging((hostingContext, logging) =>
{
if (hostingContext.HostingEnvironment.IsDevelopment())
{
logging.AddConfiguration(hostingContext.Configuration.GetSection("Logging"));
logging.AddConsole();
logging.AddDebug();
}
})
.UseIISIntegration()
.UseDefaultServiceProvider((context, options) =>
{
options.ValidateScopes = context.HostingEnvironment.IsDevelopment();
})
.UseStartup<Startup>()
.Build();
有没有人知道如何解决这个问题?
答案 0 :(得分:2)
我对此没有很好的答案。我遇到的问题与您描述的相同。我将VS更新到15.8.1,问题停止了。所以我认为问题出在VS。