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,
Samthere 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" <ssavvakis@.hotmail.com> wrote in message
news:c0cf532c.0411012208.64839b79@.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
No comments:
Post a Comment