Multiple Application_Start events firing

After spending 4 days, I have finally found the problem out! If you change any file in Bin directory, IIS resets your application and Application pool. For me, it was because of log.txt file that my program used to write in Bin directory. I changed the log file path and the problem has been vanished!


We had a similar situation happen only to discover that it was because we had done an assembly rename and had two copies of the same code referencing that assembly existed, versionA.dll and versionB.dll. So it was being called twice because of that!


We eventually realised that this was down to our IIS configuration.

Some time ago a decision was made to rename the virtual directory used for this website. This was done by adding a whole new virtual directory configuration, leaving the previous one in place. Essentially we had two virtual directories pointing at the same ASP.NET app!

The migration to the new virtual directory was never completed, so parts of the website still referenced the old one. Hence two Application_Start events...

The fix was to change to setup to the old virtual directory in IIS to be A redirection to a URL with the URL set to /NewVirtualDirectory$S$Q