Solved

global.asax not working in ASP.NET 2.0

Posted on 2009-06-30
3
925 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Needing an event fired when a row is added on a datagridview 4 36
DataGridView Events ? 3 37
Error on Add method 1 38
Gridview alignment 1 10
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
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…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

895 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

11 Experts available now in Live!

Get 1:1 Help Now