Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 234
Juri Avatar asked Jan 07 '23 08:01

Juri


1 Answers

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());
});
like image 126
Domysee Avatar answered Jan 09 '23 22:01

Domysee