Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why are the Global.asax events not firing in my ASP .NET website?

Tags:

asp.net

I've been developing an ASP .NET 3.5 web application against Cassini, the built-in web development server, rather than against IIS.

In my Global.asax file, in the Application_Start event handler, I have some code which logs the fact that the website has started up. This all works fine with Cassini.

Since deploying the site to a virtual directory on a test server using IIS6, I am finding there are no log entries being written, and so I'm concluding that the Application_Start handler is not firing.

I then tried removing the virtual directory and running the site directly out of the root of the website on the test server, but it didn't make any difference - still no log entry for application start.

I know these events should fire irrespective of my deployment environment, has anyone got any ideas what is going wrong here?

like image 982
gilles27 Avatar asked Jun 22 '09 16:06

gilles27


People also ask

Can we run ASP.NET application without global ASAX file?

An ASP.NET site can run without the global.

What are the event handlers in global ASAX?

Application_Error() – fired when an error occurs. Session_End() – fired when the session of a user ends. Application_End() – fired when the web application ends. Application_Disposed() - fired when the web application is destroyed.


1 Answers

I had a similar problem and I was wrestling with it for several days. The initial problem was something else - cookies not being set in Application's EndRequest handler. Finally I somehow managed to realize, that the problem actually was that the event is not being fired at all. It took some time to find that out, because all was working fine on my machine. But on the production server - quiet as a tomb.

I am only writing this, because I really hope to save from troubles at least one person.

The real reason for the problem was a missing global.asax file on the production server.

The global.asax file was present on my computer, because the development environment is located there. I had prepared a deployment bat file, which coppies files from the development folder, removes the unnecessary ones and makes a package. Well - the global.asax file was marked for deletion in that script. After starting to deploy it all the problems went away.

I hope I helped.

like image 87
liliancho Avatar answered Oct 15 '22 23:10

liliancho