Custom error message using Application_Error

G

Guest

Hi!
I am using the following code to redirect and display custom error message.
But its not working properly. Its giving the same error instead of the cusotm
error

web.config :

<configuration>
<system.web>
<httpRuntime maxRequestLength="4000"/>
</system.web>
</configuration>

Global.asax :

If Path.GetFileName(Request.Path) = _
"UploadForm.aspx" Then
' Get the error details
Dim appException As System.Exception = _
Server.GetLastError()
Dim checkException As HttpException = _
CType(appException, HttpException)
' Verify the expected error
If checkException.GetHttpCode = 400 And _
checkException.ErrorCode = -2147467259 Then
' Error 400 = bad request, user
' tried to upload a file that's too large
Session("ImageTooLarge") = True
Server.ClearError()
' Go to the original target page
Response.Redirect("UploadForm.aspx")
End If
End If
Thanks,
Baren
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,521
Members
44,995
Latest member
PinupduzSap

Latest Threads

Top