5

I used Visual Studio 2008 to publish my asp.net website. When I bring up the website on the server (Windows 2008 server), I noticed that the code in global.asax was not running. My Global.asax body is similar to:

<%@ Application Language="C#" %>
<script runat="server">
    protected void Application_Start()
    {
        // Initialize some site settings like a task scheduler
    }

    protected void Application_End(object sender, EventArgs e)
    {
        // Perform some clean up code
    }
</script>

There is a App_global.asax.dll in the compiled websites bin folder, but that does not seem to help.

Is there a configuration option that I'm missing? Removing the App_global.asax.dll and using the original global.asax with the precompiled website works fine.

Jim Geurts
  • 20,189
  • 23
  • 95
  • 116

6 Answers6

6

The only answer I've found is to include global.asax (with logic) in the compiled output folder.

Jim Geurts
  • 20,189
  • 23
  • 95
  • 116
  • 1
    I really interest it, Could you please explain more detail about how to include global.asax in the compiled output folder – Frank Myat Thu Nov 14 '12 at 05:11
4

I had a similar problem and managed to resolve it by removing the PrecompiledApp.config file from the website's root folder on our development server.

I think that this may have been transferred to the server when publishing from Visual Studio.

Jonathan Williams
  • 2,015
  • 1
  • 19
  • 23
  • In my case VS2012, published website has both global.asax and the app_global.dll but the precompiledapp.config file was missing(because i manually deleted unknowingly). Adding this config file solved my issue. – Esen Feb 02 '13 at 14:06
1

There are some solutions in this post which fixes the problem for some people, but not all. You could try them and see if it works for you.

keyboardP
  • 68,824
  • 13
  • 156
  • 205
1

I had the similar problem after publishing precompiled ASP.NET project under .NET 4 and IIS 7.0. Global application was not running at application start, then after placing PrecompiledApp.config to the server my problem was solved and compiled Global.asax file named App_global.asax.dll came to the front of life cycle and running.

Ali Shams
  • 11
  • 2
1

Make sure that you have all necessaries dlls included in your project, it's also a good idea, to compile your projects, compare dlls versions, and if these doesn't match, manually replace them into each folder, so you can be sure that your are running the right Dlls version.

This worked for me.

Oskar_
  • 11
  • 2
0

I think renaming Application_Start() to Application_OnStart() would solve the problem.

Reshad
  • 49
  • 1
  • 11