Page_Error doesn't render output

B

Buddy Ackerman

I have a page where users upload files. I have the maxRequestLength set and
have created a Page_Error procedure to trap the error when someone load a
file that is larger than the maxRequestLength. The problem is that the page
does not render. I either get a "Document Contains No Data" message or the
browsers just sits there loading for what appears to
al eternity. Here's the Page_Error procedure:

Sub Page_Error(ByVal sender As Object, ByVal e As EventArgs)
Dim objErr As System.Exception
objErr = Server.GetLastError().GetBaseException()

Connect() 'Connects to the database

'Checks to see if the error is caused by exceeding the
maxRequestLength value
If objErr.Message.ToString() = "Maximum request length exceeded."
RenderPage("The file uploaded exceeds the maximum allowed
size.") 'outputs page data using response.write()
Server.ClearError() 'Clears the error so that it is not
processed by the Application_Error procedure
End If

di.disconnect() 'Clears the database connection
End Sub


The RenderPage procedure appears to be doing it what it's supposed to be
doing in that I can watch the database and see that it's executing the
stored procedures in that are called in this procedure.

I tried to changing the procedure to this:

Sub Page_Error(ByVal sender As Object, ByVal e As EventArgs)
Dim objErr As System.Exception
objErr = Server.GetLastError().GetBaseException()

Connect() 'Connects to the database


'Checks to see if the error is caused by exceeding the
maxRequestLength value
If objErr.Message.ToString() = "Maximum request length exceeded."
response.write("Test")
Server.ClearError() 'Clears the error so that it is not
processed by the Application_Error procedure
End If

di.disconnect() 'Clears the database connection
End Sub


But the response that I get is the "Document Contains No Data" message.


What is wrong with this procedure?



--Buddy
 
A

Alvin Bruney [MVP - ASP.NET]

attach the debugger to the page_error routine and step thru it. observing
the database transaction isn't helping. you need to step thru your code.

--
Regards,
Alvin Bruney - ASP.NET MVP

[Shameless Author Plug]
The Microsoft Office Web Components Black Book with .NET
Now available @ www.lulu.com/owc, Amazon.com etc
 

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,968
Messages
2,570,150
Members
46,697
Latest member
AugustNabo

Latest Threads

Top