Here is my controller code. my controller return 401 status code successfully.
How to return a 401 error message with my custom message
[HttpGet]
[Authorize(Roles = "reader")]
public async Task<IActionResult> GetAllBlogsAsync()
{
// get data from repository
var blogs = await blogRepository.GetAllAsync();
// mapping Domain to DTO
var blogsDTO = mapper.Map<List<Models.DTO.Blog>>(blogs);
// return results
return Ok(blogsDTO);
}
My expected Output is "401 UnAuthorized"
Advance Thanks.