IISHttpServer-未指定authenticationScheme,未找到DefaultChallengeScheme
我正在尝试将核心WebAPI 2.2(进程内或进程外)部署到IIS 7.5。我得到下面的错误,下面是代码 失败:Microsoft.AspNetCore.Server.IIS.Core.IISHttpServer[2] 连接ID“156364979907840974971”,请求ID“8000007e-0000-d900-b63f-84710c7967bb”:应用程序引发了未处理的异常。 System.InvalidOperationException:未指定authenticationScheme,并且未找到DefaultChallengeScheme。 位于Microsoft.AspNetCore.Authentication.AuthenticationService.ChallengeAsync(HttpContext上下文、字符串方案、AuthenticationProperties) 位于Microsoft.AspNetCore.Mvc.ChallengeResult.ExecuteResultAsync(ActionContext上下文) 位于Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeResultAsync(IActionResult) 在Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeNextResultFilterAsyncTFilter,TFilterAsync 位于Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Rethrow(ResultExecutedContext) 在Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.ResultNext[TFilter,TFilterAsync](状态和下一步,范围和范围,对象和状态,布尔值和已完成) 在Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeAllwaysRunSultFilters()上 在Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeFilterPipelineAsync()中 在Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeAsync()上 位于Microsoft.AspNetCore.Routing.EndpointMiddleware.Invoke(HttpContext HttpContext) 位于Microsoft.AspNetCore.Routing.EndpointRoutingMiddleware.Invoke(HttpContext HttpContext) 位于Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware.Invoke(HttpContext上下文) 位于swashback.AspNetCore.SwaggerUI.SwaggerUIMiddleware.Invoke(HttpContext HttpContext) 位于swashback.AspNetCore.Swagger.SwaggerMiddleware.Invoke(HttpContext-HttpContext,ISwaggerProvider-swaggerProvider) 在Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext上下文)中 位于Microsoft.AspNetCore.Server.IIS.Core.iishttpcontextroft`1.ProcessRequestAsync() Program.csIISHttpServer-未指定authenticationScheme,未找到DefaultChallengeScheme,iis,asp.net-core-webapi,Iis,Asp.net Core Webapi,我正在尝试将核心WebAPI 2.2(进程内或进程外)部署到IIS 7.5。我得到下面的错误,下面是代码 失败:Microsoft.AspNetCore.Server.IIS.Core.IISHttpServer[2] 连接ID“156364979907840974971”,请求ID“8000007e-0000-d900-b63f-84710c7967bb”:应用程序引发了未处理的异常。 System.InvalidOperationException:未指定authenticationSche
public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseIIS()
.UseStartup<Startup>();
您需要什么身份验证?如果您需要
windowsAuthentication
,您需要在IIS中访问您的网站,Authentication
->设置windowsAuthentication
已启用。
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();
}