【发布时间】:2021-08-05 14:26:30
【问题描述】:
打开显示 youtube 视频的页面时,我在不同的浏览器中遇到很多错误。
我查看了该主题,结果发现它与“Cros”有关,我尝试按照步骤启用该主题,但没有运气,
这是我在 startup.cs 中所做的,我使用的是 .net core 5
public void ConfigureServices(IServiceCollection services)
{
services.AddHsts(options =>
{
});
services.AddDbContextPool<ApplicationDBContext>(options =>
options.UseSqlServer(
Configuration.GetConnectionString("DefaultConnection")
));
services.AddIdentity<ApplicationUserModel, IdentityRole>(options =>
{
}).AddEntityFrameworkStores<ApplicationDBContext>()
.AddDefaultTokenProviders();
services.AddCors(options =>
{
options.AddDefaultPolicy(builder =>
{
builder.AllowAnyOrigin().
AllowAnyMethod().
AllowAnyHeader();
});
});
services.AddControllersWithViews();
services.Configure<ForwardedHeadersOptions>(options =>
{
options.KnownProxies.Add(IPAddress.Parse("10.0.0.100"));
});
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
app.UseForwardedHeaders(new ForwardedHeadersOptions
{
ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto
});
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
else
{
app.UseExceptionHandler("/Home/Error");
app.UseHsts();
}
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseRouting();
app.UseCors();
app.UseAuthentication();
app.UseAuthorization();
app.UseEndpoints(endpoints =>
{
endpoints.MapControllerRoute(
name: "default",
pattern: "{controller=Home}/{action=Index}/{id?}");
});
}
}
【问题讨论】:
-
乍一看,这看起来像是 Safari 正在阻止内容。
-
CORS 不会是这里的问题。您是在运行广告拦截器,还是有内容安全策略 (CSP)?
标签: .net asp.net-mvc asp.net-core