By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,193 Members | 1,794 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,193 IT Pros & Developers. It's quick & easy.

maxRequestLength and Trap Page Not Found error

P: n/a
sam
Hi,

I have seen many posts about this problem and no resolution.

I have set the maxRequestLength to 200K as I don't want anyone
uploading files to the server greater than this size.

I have put code into Application_BeginRequest and Application_Error to
try and trap the error of "Page Not Found". Nothing seems to stop the
inevitable of the browser going to the "Page Not Found" page. I have
even put in the web.config custom errors, trapping the 404 error and
also set a defaultRedirect. None of this has any difference.

In Application_BeginRequest I have:

protected void Application_BeginRequest(Object sender, EventArgs e)
{
// stop the page continuing if the post is greater than 300K (this
// caters any text uploaded with the form submit
if (Context.Request.ContentLength > 300000)
{
Response.Clear();
Response.Redirect("ErrorPage.aspx", true);
}
}

It does break into here, and it does run the Response.Redirect
command, yet.. I am still re-directed to the Page Not found page. I
have breakpoints everywhere and no matter where I try to trap the
error, it still goes to the Page not found page. Even tried using
Page_Error on the page where the upload is taking place.

Has anyone got any further ideas? I have searched Google over and over
and everyone seems to have the same problem but with no solutions. :|

Thanks,
Sam
Nov 18 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
there is no solution. the http protocol has no support for stopping a file
upload and returning an error. the only way asp.net can stop the upload is
to close the connection when the max size is reached. this causes a network
error at the browser, and the browser displays the error message of its
choice - generally page not found because it the request for page never
completed.

-- bruce (sqlwork.com)
"sam" <ss*******@hotmail.com> wrote in message
news:c0**************************@posting.google.c om...
Hi,

I have seen many posts about this problem and no resolution.

I have set the maxRequestLength to 200K as I don't want anyone
uploading files to the server greater than this size.

I have put code into Application_BeginRequest and Application_Error to
try and trap the error of "Page Not Found". Nothing seems to stop the
inevitable of the browser going to the "Page Not Found" page. I have
even put in the web.config custom errors, trapping the 404 error and
also set a defaultRedirect. None of this has any difference.

In Application_BeginRequest I have:

protected void Application_BeginRequest(Object sender, EventArgs e)
{
// stop the page continuing if the post is greater than 300K (this
// caters any text uploaded with the form submit
if (Context.Request.ContentLength > 300000)
{
Response.Clear();
Response.Redirect("ErrorPage.aspx", true);
}
}

It does break into here, and it does run the Response.Redirect
command, yet.. I am still re-directed to the Page Not found page. I
have breakpoints everywhere and no matter where I try to trap the
error, it still goes to the Page not found page. Even tried using
Page_Error on the page where the upload is taking place.

Has anyone got any further ideas? I have searched Google over and over
and everyone seems to have the same problem but with no solutions. :|

Thanks,
Sam

Nov 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.