Why Cors doesn't work after update to beta8 on ASP.NET 5?

耗尽温柔 提交于 2019-12-23 14:38:54

问题


I have updated ASP.NET 5 to beta8 and changed the dependency to "Microsoft.AspNet.Cors": "6.0.0-beta8".

After that i get an error in ConfigureServices in line

services.ConfigureCors(options => { options.AddPolicy("AllowAllOrigins", builder => builder.AllowAnyOrigin()); });

Error CS1929 'IServiceCollection' does not contain a definition for 'ConfigureCors' and the best extension method overload 'MvcCorsMvcCoreBuilderExtensions.ConfigureCors(IMvcCoreBuilder, Action)' requires a receiver of type 'IMvcCoreBuilder' WebAPI.DNX 4.5.1 C:...\Startup.cs

How can i fix it and activate CORS?


回答1:


The name of the method has changed to AddCors.
So now you should use services.AddCors() instead of services.ConfigureCors():

services.AddCors(options =>
{
    options.AddPolicy("AllowAllOrigins", builder => builder.AllowAnyOrigin());
});


来源:https://stackoverflow.com/questions/33170468/why-cors-doesnt-work-after-update-to-beta8-on-asp-net-5

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!