Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Global.asax not executed in ASP.NET application

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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
Make the most of your online learning experience.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
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…

609 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