iayti/CleanArchitecture

Authorize with Policy show 'The type or namespace could not be found'

chuki2 opened this issue · 0 comments

Hi, I facing the issues with Authorize attribute when using policy

Since in your code using custom authorize class, so I unable to implement policy here.

If using Microsoft.AspNetCore.Authorization.AuthorizeAttribute, then the authorization is not working.

Example

//Need use this, or else show an error 'The type or namespace could not be found'
using AuthorizeAttribute = Microsoft.AspNetCore.Authorization.AuthorizeAttribute;


[HttpPost]
[Route("uom")]
[Authorize(Policy = "user.read.policy")] // Is not working
[ProducesResponseType(typeof(ServiceResult<ItemUomDto>), (int)HttpStatusCode.OK)]
public async Task<ActionResult<ServiceResult<ItemUomDto>>> Create([FromBody] CreateItemUomCommand command)
{
     return Ok(await Mediator.Send(command));
}

Any idea how we can solve?