I have a custom HttpModule for authentication. In the AuthenticateRequest event handler of the module I check if a custom SSO ticket is available and in that case perform some authentication logic.
If the SSO ticket is available, but incorrect, I would like to show a friendly error message to the user. I would prefer to be able to somehow set HTTP Status 401 (Unauthorized, used when authentication fails) and pass on a meaningful error message from the http module.
I would then like the MVC application to somehow get this information and use it to render a custom 401 error page which includes the meaningful error message from the module.
What's the best way to raise the error in the http module and what's the best way to have it display the error using the MVC application (to get the error message in the MVC application's layout)?