[英]ASP.Net Core Web Api access-control-max-age not being sent in the response header
I have the SetPreFlightMaxAge in the Startup.cs.我在 Startup.cs 中有 SetPreFlightMaxAge。 But the chrome Inspect > Network tab doesn't show it in the Response Headers.
但 chrome Inspect > Network 选项卡未在响应标头中显示。
Startup.cs启动.cs
app.UseCors(o =>
{
o.WithOrigins(allowedDomains.ToArray())
.SetPreFlightMaxAge(TimeSpan.FromMinutes(10))
.AllowAnyHeader()
.AllowAnyMethod()
.AllowCredentials()
});
Response Headers (GET method): In addition to some other headers it sends these headers.响应标头(GET 方法):除了一些其他标头之外,它还发送这些标头。 There is a max-age in the third line below, but that's not the 10 mins value set in the Startup.cs
下面第三行有一个 max-age,但这不是 Startup.cs 中设置的 10 分钟值
access-control-allow-credentials: true
access-control-allow-origin: ...
set-cookie: ...
strict-transport-security: max-age=2592000
vary: Origin,Accept-Encoding
Response Headers (OPTIONS method):响应标头(OPTIONS 方法):
access-control-allow-credentials: true
access-control-allow-headers: ...
access-control-allow-origin: ...
set-cookie: ...
In .NET core 3.1 try adding it in ConfigureServices在 .NET 核心 3.1 中尝试将其添加到 ConfigureServices
services.AddCors(o => o.AddPolicy("xyzpolicy", builder =>
{
builder.AllowAnyOrigin()
.AllowAnyMethod()
.AllowAnyHeader()
.SetPreflightMaxAge(TimeSpan.FromMinutes(10));
}));
They say its caped to 2 hours for Chromium-based browsers他们说基于 Chromium 的浏览器最多需要 2 小时
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.