Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / May 2004

Tip: Looking for answers? Try searching our database.

Application_Error in Global.asax

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Thom Little - 11 May 2004 09:59 GMT
I have an ASP.NET application developed in Visual Studio .NET 2003.

The Application_Error in Global.asax never gains control.  If the following
is in Global.asax and I cause a Divide-by-zero the message never appears.

protected void Application_Error( Object sender, EventArgs e )
  {
  Response.Write("Error" );
  Server.ClearError( );
  }

What am I overlooking?

Signature

-- Thom Little -- www.tlaNET.net -- Thom Little Associates, Ltd.
--

Marek - 11 May 2004 11:42 GMT
Try naming your handler Application_OnError

> I have an ASP.NET application developed in Visual Studio .NET 2003.
>
[quoted text clipped - 8 lines]
>
> What am I overlooking?
Thom Little - 11 May 2004 12:24 GMT
Thanks but that didn't help.

I am hoping someone who uses the Global.asax will point out the obvious
thing I am overlooking.

Signature

-- Thom Little -- www.tlaNET.net -- Thom Little Associates, Ltd.
--

> Try naming your handler Application_OnError
>
[quoted text clipped - 11 lines]
> >
> > What am I overlooking?
Marek - 11 May 2004 18:34 GMT
Hi,

Well, looks like I confused VS NET with Web Matrix.

Marek

> Thanks but that didn't help.
>
[quoted text clipped - 17 lines]
> > >
> > > What am I overlooking?
Alvin Bruney [MVP] - 11 May 2004 14:57 GMT
Typically, the error is not in the global asax file but in the page. You
most likely have hooked up your error event at the page level (I believe vb
does that by default, not sure). Have a look at your initializateComponent
routine. Look for this line Page.Error += ....
This prevents run-time errors from percolating up the stack to the global
level. In effect, exceptions are swallowed at the page level if they aren't
caught. You can choose to remove it or transfer your code in global asax to
the page level error event handler.

Signature

Regards,
Alvin Bruney
[ASP.NET MVP http://mvp.support.microsoft.com/default.aspx]
Got tidbits? Get it here... http://tinyurl.com/27cok

>I have an ASP.NET application developed in Visual Studio .NET 2003.
>
[quoted text clipped - 9 lines]
>
> What am I overlooking?
Marek - 11 May 2004 18:32 GMT
Hi,

In C# ASP.NET Web Application project error handling is not done at page
level by default. The problem can be that by default several handlers are
exposed in Global asax.cs but they are NOT assigned to events. If error
handling is supposed to be at the HttpApplication level access property
editor for Global.asax.cs[Design] select events tab and assign a proper
handler to the Error event. This can be also done manually in
InitializeComponent().

regards,
Marek

> Typically, the error is not in the global asax file but in the page. You
> most likely have hooked up your error event at the page level (I believe vb
[quoted text clipped - 18 lines]
> >
> > What am I overlooking?
Thom Little - 12 May 2004 00:06 GMT
I created a new C# project.  I added a button.  The button issues a throw
...

  throw new Exception("AAAAAAAA" );

Global.asax contains one change ...

 protected void Application_Error(Object sender, EventArgs e)
 {
 Response.Write("Application_Error" );
 }

When I run the application and click the button I get the default error
excepting message page.

I can find no way to manipulate any event properties in Global.asax using
the Designer.

Signature

-- Thom Little -- www.tlaNET.net -- Thom Little Associates, Ltd.
--

> Hi,
>
[quoted text clipped - 35 lines]
> > >
> > > What am I overlooking?
Marek - 12 May 2004 00:29 GMT
Hi Thom,

I am not sure if this is the real problem you're facing but try the
folowing:
When editing Global.asax.cs press shift-F7. You should get
Global.asax.cs[Design] designer. Then access property editor and assign
Application_Error handler to Error event.

Marek

> I created a new C# project.  I added a button.  The button issues a throw
> ...
[quoted text clipped - 55 lines]
> > > >
> > > > What am I overlooking?
Thom Little - 12 May 2004 01:45 GMT
But ... the light is so much better over here ...

Thanks.  That was the problem.  I was putting out the message and then it
was getting overlaid by the default error page.

When I added Context.ClearError() in the Application_Error the default page
stopped overlaying my message.

Thank you both for the help.

BTW I am using Visual Studio .NET 2003 and can find no way to access event
assignments from the designer.  I did nothing special to make an assignment
and the Application_Error gained control as it should.

Signature

-- Thom Little -- www.tlaNET.net -- Thom Little Associates, Ltd.
--

> Hi Thom,
>
[quoted text clipped - 69 lines]
> > > > >
> > > > > What am I overlooking?
Jerry Pisk - 12 May 2004 01:12 GMT
If you don't want the default error page to show up you need to clean up
those execution errors. Just add Context.ClearError() call to the error
handler. And the error handle has to be named Application_OnError.

Jerry

> I created a new C# project.  I added a button.  The button issues a throw
> ...
[quoted text clipped - 55 lines]
> > > >
> > > > What am I overlooking?

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.