I am using below code to catch HttpRequestValidationException. But the problem is it navigates to different Page.
I want to show "Invalid Input" Error Message on the same page where user is entering the information and clicking on Submit button.
protected void Application_Error(object sender, EventArgs e)
{
var context = HttpContext.Current;
var exception = context.Server.GetLastError();
if (exception is HttpRequestValidationException)
{
Response.Clear();
Response.StatusCode = 200;
Response.Write(@"<html><head></head><body>Invalid Input</body></html>");
Response.End();
return;
}
}