Solved

Global.asax not executed in ASP.NET application

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
countHi challenge 25 101
mapShare challenge 13 91
wordmultiple challenge 12 121
Remove Password Protection from pdf (with password) using an command line executable 5 30
Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
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…
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…

863 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

26 Experts available now in Live!

Get 1:1 Help Now