Skip to content

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

@chuki2

Description

@chuki2

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions