添加允许的Header不允许.NET Core 3.1中的所有标头
在我的.NET CORE 3.1启动程序中,我有类似的东西:
public void ConfigureServices(IServiceCollection services)
{
services.AddCors(options =>
{
options.AddDefaultPolicy(
builder =>
{
builder.AllowAnyHeader();
builder.AllowAnyMethod();
builder.AllowAnyOrigin();
});
});
}
我期望allowanheader
会添加“ access-control-allow-hally-hethods”:“获取,发布,张贴,放置,删除,删除,选项“;
to响应标头,但是当我以[httpdelete]
配置的方法调用删除时,我在响应标头中看到以下内容:
> Access-Control-Allow方法→GET
(没有删除或选项)
,那么我该怎么办才能查看响应标头中允许的所有方法?
In my .NET Core 3.1 Startup program, I have something like this:
public void ConfigureServices(IServiceCollection services)
{
services.AddCors(options =>
{
options.AddDefaultPolicy(
builder =>
{
builder.AllowAnyHeader();
builder.AllowAnyMethod();
builder.AllowAnyOrigin();
});
});
}
I was expecting that AllowAnyHeader
would add "Access-Control-Allow-Methods": "GET,POST,PUT,DELETE,OPTIONS";
to the response header, but when I call a DELETE in a method configured with [HttpDelete]
in the Controller, I see the following in the response header:
access-control-allow-methods → GET
(no DELETE or OPTIONS)
So, what should I do to see all methods allowed in the response header?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以将其改为在配置中使用
,也可以使用
,然后在配置中使用它
You can use this instead in Configure
or you should use
then use it in Configure