Tag: 跨域策略

.NET Core UseCors()不添加标头

这将是Access-Control-Allow-Origin标头如何工作的重复? ,但那里的方法也不适合我。 我希望我只是缺少一些东西。 我试图从我的.NET Core Web API的响应中获取一个Access-Control-Allow-Origin标头,我通过AJAX访问它。 我尝试过几件事。 除非另有说明,否则所有内容都在Startup.cs文件中。 方法1 根据Microsoft文档 : public void ConfigureServices(IServiceCollection services) { // Add database services.AddDbContext(options => options.UseSqlServer(Configuration.GetConnectionString(“DbConnection”))); // Add the ability to use the API with JSON services.AddCors(); // Add framework services. services.AddMvc(); } public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) { loggerFactory.AddConsole(Configuration.GetSection(“Logging”)); loggerFactory.AddDebug(); if (env.IsDevelopment()) { using […]