Solved

global.asax not working in ASP.NET 2.0

Posted on 2009-06-30
3
919 Views
Last Modified: 2013-11-07
Last night we upgraded from ASP.NET 1.1 to ASP.NET 2.0.  I have noticed that our Application_Error handler is not firing from Global.asax.

In visual studio we have a class, Epic.Web.Global.  See source code below.  The Application_Error is not firing but instead a log is written to the windows event log regarding the unhandled exception.

We used VS 2008 to upgrade our project from VS 2003 but the actual Global.asax file has never been part of our VS project file -- it's just a file we dropped on IIS in the application root directory.  The compiled Epic.Web.DLL file is dropped in application root\bin directory.

I have since tried adding a new Global.asax file to the VS project but then it wants to do a code behind file and drop the .cs file in App_Code.  I don't want to do that -- I want to use our DLL using inherits in Global.asax but I haven't figured out how to make it work.

This worked fine in .NET 1.1 and should be simple but I haven't found the quirk yet.  I have found articles on here and on google regarding people with similiar problems but haven't found an answer that works for us.  There was something regarding PrecompiledApp.config but it's not a file we have.  We have web.config and it does have custom errors turned on.


Thanks

Our Global.asax file:

 

<%@ Application Language="C#" Inherits="Epic.Web.Global" %>

 

Our Global.cs file:

 

namespace Epic.Web

{

    public class Global : System.Web.HttpApplication

    {

        protected void Application_Error(object o, EventArgs e)

        {

          Exception exception = Server.GetLastError();

          // do work

         Server.ClearError(); // tried with and without this

        }

    }

}

Open in new window

0
Comment
Question by:DJE-
  • 2
3 Comments
 
LVL 3

Expert Comment

by:tpsl
ID: 24751519
As far as I know with asp.net 2.0 you need to place all .cs files in app_code...

which is why it is asking you to place it in that folder. Otherwise you won't be able to access that file.

Why don't u want it in app_code folder?

0
 

Author Comment

by:DJE-
ID: 24753779
I don't want source code on a production server -- not good practice.

We pre-compile everything and in the past (.NET 1.1) there was no problem placing Epic.Web.DLL (our precompiled DLL file) in the bin folder and using "Inherits" in the asax file.
0
 

Accepted Solution

by:
DJE- earned 0 total points
ID: 24764311
It turns out our Application_Error method itself was throwing another exception, causing it to not behave as expected.  Some of our "// do work" code within Application_Error did not run the same in 3.5 as it did under 1.1 (without error).  So you can still use Inherits in Global.asax with all of the source precompiled in a .DLL file, good!
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now