AuthorizationPolicy named: 'UmbracoFeatureEnabled' was not found

Hi Team,

I am creating Core 6 web api project for Umbraco 9.5 version. I create one api class which is

[Route("api/StoreLocator")]
[ApiController]
public class StoreLocatorController : UmbracoApiController
{

now i added some default settings in start.up class file which is

 services
                 .AddSwaggerGen()
                 .AddUmbraco(_env, _config)
                 .AddBackOffice()
                 .AddWebsite()
                 .AddComposers().Build();

 app.UseUmbraco()
                .WithMiddleware(u =>
                {
                    u.UseBackOffice();
                    u.UseWebsite();
                    u.UseUmbracoCoreMiddleware();
                })
                .WithEndpoints(u =>
                {
                    u.UseInstallerEndpoints();
                    u.UseBackOfficeEndpoints();
                    u.UseWebsiteEndpoints();
                });

when i run this web api project and try to call api…i am getting the error response which is

System.InvalidOperationException: The AuthorizationPolicy named: 'UmbracoFeatureEnabled' was not found.
   at Microsoft.AspNetCore.Authorization.AuthorizationPolicy.CombineAsync(IAuthorizationPolicyProvider policyProvider, IEnumerable`1 authorizeData)
   at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
   at Swashbuckle.AspNetCore.SwaggerUI.SwaggerUIMiddleware.Invoke(HttpContext httpContext)
   at Swashbuckle.AspNetCore.Swagger.SwaggerMiddleware.Invoke(HttpContext httpContext, ISwaggerProvider swaggerProvider)
   at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)

Could anyone please help me on this issue.


This is a companion discussion topic for the original entry at https://our.umbraco.com/forum/109425-authorizationpolicy-named-umbracofeatureenabled-was-not-found