473,387 Members | 1,942 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

maxRequestLength and Trap Page Not Found error

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
1 2442
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Peter Row | last post by:
Hi, To allow users to upload files larger than 4MB in size I added: <httpRuntime maxRequestLength="102400" executionTimeout="600" /> ...to my web.config file. Fair enough this works fine....
0
by: Jack Wright | last post by:
Dear All, I have a web Application "http://localhost/Web/WebForm1.aspx" that calls a WebService from "http://localhost/webserviceapp/service1.asmx"...I have set the executionTimeout to 10 secs in...
25
by: moondaddy | last post by:
I have an application where users need to upload images and in my web.config file I have a setting like this: <httpRuntime maxRequestLength="512" /> Which restricts image larger than 500k from...
2
by: Jay | last post by:
I have been trying to use maxRequestLength to stop users from uploading large files. It put this code in the web.config file: <httpRuntime maxRequestLength="128" /> --The upload works...
2
by: Joseph Geretz | last post by:
I'm developing a Web Service using DIME to download and upload files from and to an IIS server. In order to increase the download filesize to unlimited, I have the following block in my App.config...
5
by: Matt Chubb | last post by:
I've searched the forums and the net and have not found a solution to this upload problem, any suggestions/help in this matter would be greatly appreciated. I'm trying to trap and display an...
2
by: Eric | last post by:
Hi All, I am working with an ASP.NET website with .NET 1.1. I want to increase the maxRequestLength value for *only* a single page (therefore, I can't set the new value in machine.config or...
1
by: bixbarton | last post by:
Does anyone know how to obtain the MaxRequestLength easily? I have found that if you do the following; object getCon = HttpContext.GetAppConfig("system.web/httpRuntime") Then look at getCon...
0
hyperpau
by: hyperpau | last post by:
Before anything else, I am not a very technical expert when it comes to VBA coding. I learned most of what I know by the excellent Access/VBA forum from bytes.com (formerly thescripts.com). Ergo, I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.