Re: How to intercept error when httpRuntime maxRequestLength is ex

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Jesse (Jesse_at_discussions.microsoft.com)
Date: 08/29/04


Date: Sun, 29 Aug 2004 09:09:07 -0700

I'm going to have to disagree with you. I have full error handling set up on
my site. Error logging in global.asax and custom error setup in web.config.

I even tried to explicity catch the System.Web.HttpException that is thrown
by exceeding the maxRequestLength and then redirecting to a friendly page.
Still no luck there. The only thing that the redirection causes to happen is
that the application_error event now gets fired 3 times. I'll get three
errors logged and still end up on the dns error page.

Go ahead and test this out by stepping through it with the debugger. I'm
getting tired of people saying to catch this problem by checking
httpPostedFile.ContentLength. You can't do it. The code will never be hit
on your page because the runtime throws the exception. So therefore you
would think that you could catch it in global.asax, and you can, but any
redirection will not work. Why? That is the question.

Don't tell me the that the client can't contact the server in these
instances. I'm stepping through it with the debugger man. Why don't you
setup a test and then you will see. You'll get hte dns error after the
server has been hit. I don't know what you mean by "the client browser could
not contact the server". It's obviously hitting the server.

Has microsoft actually setup an examlpe of this? I can send a simple
example solution to anybody that needs proof.

"Hermit Dave" wrote:

> its a 2 part thing. if the client browser could not contact the server in
> the first place then it will throw its on error in the form of server not
> found / dsn error
>
> however as Paul mentioned if the error occurred in your code.. then you
> could handle it. sometimes the server is busy serving and doesnt respond...
> at that point if you have your custom errors page then it will redirect it
>
> --
>
> Regards,
>
> Hermit Dave
> ()
>
> "Jesse" <Jesse@discussions.microsoft.com> wrote in message
> news:5BA46BAC-7F8A-4349-8BE2-DE6F4B198CAC@microsoft.com...
> > Unfortunately this does not work. I have tried redirecting in the
> > application_error event but for this particular exception, it seems that
> > asp.net just ignors everything and redirects to the "can't find server or
> dns
> > error" page. I have customErrors setup in web.config and that seems to be
> > ignored as well.
> >
> > Is there any way we can get microsoft to give us a definitive explanation
> on
> > this? Are we basically just stuck displaying an unfriendly page to the
> user
> > that doesn't give them any clue about what happened?
> >
> > Jesse
> >
> > "Paul Glavich [MVP - ASP.NET]" wrote:
> >
> > > You should be able to handle this in the Application_Error event in the
> > > Global.asax. The code below just shows some example code
> > >
> > > void Application_Error(object sender, EventArgs e)
> > > {
> > > SomeStringVar = .Server.GetLastError.Message();
> > > Server.Transfer("Errors.aspx")
> > > Server.ClearError()
> > > }
> > >
> > > You could also have a web.config setting that captures that particular
> Http
> > > error number and redirects accordingly. Something like :-
> > > <configuration>
> > > <system.web>
> > > <customErrors defaultRedirect="GenericError.htm"
> > > mode="RemoteOnly">
> > > <error statusCode="500"
> > > redirect="InternalError.htm"/>
> > > </customErrors>
> > > </system.web>
> > > </configuration>
> > >
> > > You could change (or add another entry) to the '500' for whatever error
> code
> > > you want.
> > >
> > >
> > >
> > > --
> > > - Paul Glavich
> > > Microsoft MVP - ASP.NET
> > >
> > >
> > > "moondaddy" <moondaddy@nospam.com> wrote in message
> > > news:O%23lzXrXYEHA.3988@tk2msftngp13.phx.gbl...
> > > > 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 being uploaded. I'm also
> > > using
> > > > the HtmlInputFile control to do the uploading. My problem is that
> when
> > > the
> > > > user's file size exceeds 512k, the page immediately redirects to the
> "The
> > > > page cannot be displayed" error page which is very confusing. The use
> > > will
> > > > think that their image is corrupt, or the website has a nasty bug in
> it.
> > > > The way this should be handled is instead of showing the nasty "The
> page
> > > > cannot be displayed" page, show a friendly page telling the user that
> they
> > > > exceeded the file limit and to upload a smaller image.
> > > >
> > > > Is there a way to intercept this and do a redirect? and if not, is
> there
> > > > any other way to handle this elegantly?
> > > >
> > > > --
> > > > moondaddy@nospam.com
> > > >
> > > >
> > >
> > >
> > >
>
>
>



Relevant Pages

  • Re: How to configure for Two different IP subnets
    ... Active Directory will go haywire in a setup like that. ... AD integrates with the local DNS, so you cannot use the DNS at your ISP ... With Server 2003 Standard ... for its internal interface (ie the VPN endpoint). ...
    (microsoft.public.windows.server.networking)
  • RE: To Setup Exchange or not to Setup Exchange...That is the Question.
    ... enough rescources to handle the load that Exchange will put on it. ... into your server in no time, so you will either have to have a very fast RAID ... You can also setup RPC over HTTP for your sales people to reteive e-mail ... phones can download a simple POP client to the phone to get E-mail. ...
    (microsoft.public.exchange.setup)
  • trouble with shared fax service
    ... I setup the shared fax service for the first time on a machine that has SBS ... Our server has one network card connected to a wireless ... Client problem: After setting up shared fax service on the server, ...
    (microsoft.public.windows.server.sbs)
  • Re: Specified network name is no longer available
    ... ISP says nothing wrong with the connection.. ... Also it works just fine if the guys make a dial up VPN connection to ... On it's own the SBS2003 server worked well, ... So Site B was setup. ...
    (microsoft.public.windows.server.sbs)
  • Re: WM 5.0 and Sprint 6700 PPC-cant sync in cradle but can throug
    ... This setup may not be correct. ... Zone Name: domainname.com ... The Internet IP address of your web server ... I can WIRELESSLY sync to the server with the 6700 PPC using the Sprint ...
    (microsoft.public.pocketpc.activesync)