public override void OnAuthorization(HttpActionContext actionContext) { try { if (Authorize(actionContext)) { return; } HandleUnauthorizedRequest(actionContext); } catch (Exception) { PetWhizzResponse IGResponse = new PetWhizzResponse() { Message = "Token Expired", Code = (Int32)ErrorCode.TOKENEXPIRED, Object = null, ObjectType = null }; actionContext.Response = actionContext.Request.CreateResponse( HttpStatusCode.OK, IGResponse ); return; } }
protected override void HandleUnauthorizedRequest(HttpActionContext actionContext) { //create custom unauthorized exception PetWhizzResponse IGResponse = new PetWhizzResponse() { Message = "Unauthorized Call", Code = (Int32)ErrorCode.UNAUTHORIZED, Object = null, ObjectType = null }; actionContext.Response = actionContext.Request.CreateResponse( HttpStatusCode.OK, IGResponse ); return; }