customerErrors not working

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

you just need to encode the html characters for suitable URL passage. there
is a few framework classes that do this for you. you can use this one
statically:

x = System.Web.HttpUtility.UrlEncode("<h2>afsdfad</h2>")
 
Hi,

Anybody can help with customErrors.

I have already set the customerErrors at the web.config.

but it didn't work for all of the aspx page.
1 of them if I put like this

http://localhost/404.aspx?<h2>afsdfad</h2>

then it gonna give the runtime error instead of redirect to the error.aspx

if I disabled the customErrors then it gonna gave this error code:

A potentially dangerous Request.QueryString value was detected from the
client (="<h2>afsdfad</h2>").
I just need to make it redirect to the errors.aspx, How can I make it works
?

thanks
JR
 
JR:

I'm not sure I understand your question, but below is an example of
redirecting to a 404 error page where the name of the error page is
"notfound.aspx" in the directory "Errors" - (GenError.aspx is another page
used for general errors):

In the Web.Config page
....
<customErrors mode="RemoteOnly" defaultRedirect="Errors/GenError.aspx">
<error statusCode="404" redirect="Errors/notfound.aspx" />
</customErrors>
....

In your aspx code page (in the Try-Catch-EndTry block):

Try
.....some code
Catch ex as FileNotFoundException
Response.Redirect("Errors/notfound.aspx", False)
End Try


Hope this helps.
 
Back
Top