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));
}
Hi, I facing the issues with
Authorize
attribute when using policySince 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
Any idea how we can solve?