I am trying to write an FilterAttribute, IExceptionFilter global error handling attribute which should serve up a custom error view. I override public void OnException(ExceptionContext context) and do
context.HttpContext.Response.Clear();
context.HttpContext.Response.TrySkipIisCustomErrors = true;
context.HttpContext.Response.StatusCode = 403;
context.ExceptionHandled = true;
context.Result = new ViewResult { ... not sure what to put here... }
which is where I am stuck.
Everything I have tried so far causes me to see internal server error pages. I suspect I want something like
context.Result = new ViewResult
{
ViewName = "~/Errors/ReadOnlyMode.cshtml",
}
However that didn’t seem to work (internal server errors…).
This should work