Can't enable CORS globally in ASP.NET web API core

Viewed 72

I configured the CorsAuthorizationFilterFactory like this

serviceCollection.AddMvc();
serviceCollection.Configure<MvcOptions>(options =>
{
    options.Filters.Add(new CorsAuthorizationFilterFactory(policyName));
});

But when I run the application received the issue:

System.TypeLoadException: 'Could not load type 'Microsoft.AspNetCore.Mvc.Cors.Internal.CorsAuthorizationFilterFactory' from assembly 'Microsoft.AspNetCore.Mvc.Cors, Version=6.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'.'

I configured some dependencies like Microsoft.AspNetCore.Mvc.Cors but I have received the same issue. Could you give me any suggestions, please?

1 Answers
Related