How can a send message to user if file uploaded exceeds the maximum limit on server side using asp.net. I have wriiten following code in global.asax
Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs)
Dim ex As New Exception
ex = Server.GetLastError()
If TypeOf ex Is HttpUnhandledException AndAlso ex.InnerException IsNot Nothing Then
ex = ex.InnerException
End If
If (ex IsNot Nothing) And ex.Message.Contains("Maximum request length exceeded") Then
Server.ClearError()
Server.Transfer("/Errors.aspx")
End If
End Sub
It does not display erros page instead get Internet Explorer cannot display the webpage
That's too late in the cycle. Test for it in Application_BeginRequest like this:
Source http://weblogs.asp.net/hosamkamel/resolving-maximum-request-length-exceeded-exception