?
Solved

Global.asax not executed in ASP.NET application

Posted on 2004-03-29
4
Medium Priority
?
1,248 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
[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
4 Comments
 

Accepted Solution

by:
ash_927 earned 1000 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

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

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

This is about my first experience with programming Arduino.
Make the most of your online learning experience.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
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…
Suggested Courses

777 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