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

I upgraded ASP.NET 5 to beta 8 and changed the dependency from "Microsoft.AspNet.Cors": "6.0.0-beta8".

After that, I get an error in ConfigureServices in the line

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

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

How can I fix it and activate CORS?

+4
source share
1 answer

AddCors.
, services.AddCors() services.ConfigureCors():

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

Source: https://habr.com/ru/post/1611939/


All Articles