Reputation: 287
How can i redirect the user to a custom error page, when HttpRequestValidationException occurred. I tried to catch it in my basecontroller :
protected override void OnException(ExceptionContext exceptionContext)
{
if (exceptionContext.Exception is HttpRequestValidationException)
{
this.View("CustomError").ExecuteResult(this.ControllerContext);
}
}
But i still get the exception : A potentially dangerous request.form value was detected from the client
Upvotes: 5
Views: 4150
Reputation: 1038720
This exception occurs much earlier in the execution of the request and cannot be handled by the OnException
method in a base controller. You could write a global exception handler as I showed in this post
.
Upvotes: 4