Question

I want to extend HandleErrorAttribute to globally handle a custom error type in my project. This what I was envisioning

  • Page user makes a request to pull a report from the site
  • The site (mvc project) needs to talk to a web api using an auth token
  • The api returns 401 with a body that contains an app code indicated it was because the token has expired
  • The site sees this and throws a TokenRefreshException
  • The site handles this globally by retrieving the refresh token from the session and using it to update the user's tokens, save it back to the session and then reattempt the action.
  • If it isn't able to refresh the token, it kills the session and redirects the user to the login page.

Is this possible and how do I implement this logic without creating an infinite loop (I'm not sure how to keep count)?

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top