Solved

Global.asax not executed in ASP.NET application

Posted on 2004-03-29
4
1,243 Views
Last Modified: 2012-08-14
I tried everuthing it just wont work. I have the following code:

<%@ import namespace="ErrLog" %>
<script language="C#" runat="server">
void Application_Error(Object sender, EventArgs e)
            {
                        Exception objError = Server.GetLastError();
                        ErrLog.ErrLogger.WriteLog(objError);
                        Server.ClearError();
            }
</script>

in my Global.asax file. It just wont get executed. It doesn't return an error, it just doesn't do anything. Everything works as if it wasn't there.

I read a post about having to restart the web site, i did that about 100 times, i tried using a codebehind page and the code above with the same results.
0
Comment
Question by:Cart_man
4 Comments
 

Accepted Solution

by:
ash_927 earned 250 total points
ID: 10720230
in your global.aspx type this
<%@ Application Codebehind="Global.asax.cs" Inherits="Namespace.Global" %>

Then in your code behind page use
using System;
using System.Collections;
using System.ComponentModel;
using System.Web;
using System.Web.SessionState;
namespace YourNamespace
{
public class Global : System.Web.HttpApplication
{
private System.ComponentModel.IContainer components = null;
  public Global()
  {
    InitializeComponent();
  }
  private void InitializeComponent()
 {    
  this.components = new System.ComponentModel.Container();
  }
 // Your other events here
  protected void Application_Start(Object sender,  EventArgs e)
 {
 }
}}
If its still not working then check for typo errors      
0
 
LVL 8

Expert Comment

by:OBonio
ID: 10723028
Is the directory where the asax is set as an application in IIS?

Start IIS Management Console, navigate to the directory, right click properties, Click Create.

This will make the directory an application and IIS will load the asax.

HTH
0

Featured Post

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
groupSumClump challenge 9 115
python sqlite question 11 46
parse convert xml feed to text (python) 2 82
program a usb light to turn on when needed 7 62
This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

776 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