iis - IISHttpServer - 没有指定 authenticationScheme,也没有找到 DefaultChallengeScheme
问题描述
我正在尝试将 Core WebAPI 2.2(InProcess 或 OutOfProcess)部署到 IIS 7.5。我得到以下错误,下面是代码。
失败:Microsoft.AspNetCore.Server.IIS.Core.IISHttpServer[2] 连接 ID“15636497907840974971”,请求 ID“8000007e-0000-d900-b63f-84710c7967bb”:应用程序引发了未处理的异常。System.InvalidOperationException:未指定 authenticationScheme,也未找到 DefaultChallengeScheme。在 Microsoft.AspNetCore.Authentication.AuthenticationService.ChallengeAsync(HttpContext context, String scheme, AuthenticationProperties properties) 在 Microsoft.AspNetCore.Mvc.ChallengeResult.ExecuteResultAsync(ActionContext context) 在 Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeResultAsync(IActionResult 结果)在 Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeNextResultFilterAsyncTFilter,TFilterAsync 在 Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker。
程序.cs
public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseIIS()
.UseStartup<Startup>();
启动.cs
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
// Configure services
services.AddAuthentication(IISDefaults.AuthenticationScheme);
ConfigureSwagger(services);
}
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
else
{
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
app.UseHsts();
}
app.UseAuthentication();
// Enable middleware to serve generated Swagger as a JSON endpoint.
app.UseSwagger();
app.UseSwaggerUI(c =>
{
c.SwaggerEndpoint("/swagger/v1/swagger.json", "MyProject.Test V1");
});
app.UseMvc();
}
解决方案
推荐阅读
- javascript - 测试反应 js 应用程序时 npm 测试失败
- javascript - 为什么 jQuery 采用原始 DOM 元素类,即使我用 jQuery 更改了它们?
- javascript - 除非调用 location.reload,否则无法取消设置 GET 参数
- solidity - 如何在 Solidity 中为函数设置默认参数
- android - 无法使用 AppBar 更改工具栏上的阴影
- java - 我在通过接口传递数据时遇到问题
- javascript - 在 Amazon Linux 中以普通用户身份运行时,Node JS 找不到模块“node-properties-parser”错误
- c - 这些函数有什么作用?
- java - 使用 AspectJ(无 Spring)仅在带注释的方法上应用方面
- javascript - Ajax 读取 JSON - 无法读取未定义的属性“名称”