?
Solved

global.asax not working in ASP.NET 2.0

Posted on 2009-06-30
3
Medium Priority
?
931 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

Quick Cloud Training

Looking for some quick training on the cloud in 2 hours or less? Check out these how-to guides in AWS, Linux, OpenStack, Azure, and more!

Question has a verified solution.

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

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses

765 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