[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

global.asax not working in ASP.NET 2.0

Posted on 2009-06-30
3
Medium Priority
?
932 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-
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

656 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