Click here to Skip to main content
15,908,020 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
New feature with asp.net 4.0 to avoid cross site scripting(XSS) is good.
Validation happens before server side event firing. So I cant use try-catch to throw exception.
I wanted to show a Useful message through custom error page when user try to enter script/html in text-box or any other input control.
Please any help.
Thanks....
Posted

1 solution

Solve.
Change in void Application_Error() in Global.asax.cs
Check type of last server error to HttpRequestValidationException and redirect to CustoErrorPage.html


C#
void Application_Error(object sender, EventArgs e)
        {
            if (typeof(System.Web.HttpRequestValidationException) ==  Server.GetLastError().GetType())
            {
                
                Response.Redirect("~/HTML/CustomErrorPage.htm");
            }

        }
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900