【发布时间】:2021-07-22 17:00:23
【问题描述】:
我加UseAuthentication();到我的startup.cs 允许cors 失败并且不允许cors,请问有什么设置命令吗? (没有 app.UseAuthentication() 没有 cors 问题)
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
app.UseHttpsRedirection();
app.UseRouting();
app.UseCors(
options => options.AllowAnyOrigin()
.AllowAnyMethod()
.AllowAnyHeader()
); app.UseHttpStatusCodeExceptionMiddleware();
app.UseAuthentication();
在我拥有的 ConfigureServices 上:
void ConfigureServices(IServiceCollection services)
{....
services.AddCors();
services.AddSSOAuthentication(Configuration, CurrentEnvironment);
services.AddControllers();
services.AddRequestLogging(opt =>
{
opt.ResponseTimeInMs = true;
opt.CookiesLoggingEnabled = false;
});
services.AddSwaggerGen();
}
【问题讨论】:
-
能否提供异常信息?
-
没有执行但我阻止了 cors 消息:(原因:CORS 请求没有成功)。
-
这能回答你的问题吗? Trouble with CORS Policy and .NET Core 3.1
标签: c# .net asp.net-core-webapi asp.net-core-3.1