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.
asax is not required by ASP.NET for a website to run. It is, however, very useful for application-level functionality (like unhandled exception logging). Save this answer.
How to add global. asax file: Select Website >>Add New Item (or Project >> Add New Item if you're using the Visual Studio web project model) and choose the Global Application Class template. After you have added the global.
The Application_Start and Application_End methods are special methods that do not represent HttpApplication events. ASP.NET calls them once for the lifetime of the application domain, not for each HttpApplication instance.
The only answer I've found is to include global.asax (with logic) in the compiled output folder.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With