Solved

Global.asax not executed in ASP.NET application

Posted on 2004-03-29
4
1,241 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
Comment Utility
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
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
mapAB Challlenge 35 84
wordmultiple challenge 12 89
How does Google get such fast response times? 5 120
move one pixel 4 41
I know it’s not a new topic to discuss and it has lots of online contents already available over the net. But Then I thought it would be useful to this site’s visitors and can have online repository on vim most commonly used commands. This post h…
This article will show, step by step, how to integrate R code into a R Sweave document
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

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

10 Experts available now in Live!

Get 1:1 Help Now