How to return custom message if Authorize fails in WebAPI
问题 In my WebAPI project, I have number of apis which are decorated with [Authorize] attribute. [Authorize] public HttpResponseMessage GetCustomers() { //my api } In case user doesn't have the right token, an access denied exception is returned to the user. But what I need is that in any such case, I need to return the custom response message as. { "StatusCode" : 403, "message": "You donot have sufficient permission" } How do I return this custom message in case authorization fails. Please note: