Reputation: 89
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?
Upvotes: 2
Views: 258
Reputation: 27815
In ASP.NET Core 3.0, some pubinternal APIs that includes Microsoft.AspNetCore.Mvc.Cors.Internal
are updated to be truly internal, which seems cause this issue.
If you want to migrate older version ASP.NET CORE App to 3.0 or above version, and enable CORS, you can refer to this doc about "Enable Cross-Origin Requests (CORS) in ASP.NET Core".
Upvotes: 1