In the last few weeks I've been noticing some problems with site updates I've made to my live server. I have an application running locally and it's running fine without problems. The app is running as a Web Application Project (WAP) and so when I update the application most of the time I only update the BIN folder and possibly one or two of the ASPX markup pages.
So I upload all files out of the BIN directory to the server and I quite frequently end up with a yellow screen of death like this:
which is not an unfamiliar dialog. If you've ever uploaded files to a live site you've probably been greeted by this dialog (or the safe redirected version thereof). When files are 'in transit' .NET can and often does detect the new file on the server even though it's incomplete and tries to load it, which fails and boom you get the above error. That's well understood (although not really an optimal way to handle this - .NET should be able to detect that this file is still being written to instead of blinding unloading and reloading assemblies - but that's another story for another day).
But what's happening to me now is that these this page keeps coming up even after the file upload to the server has been completed. If I refresh the above page I will see the app cycling through the BIN directory assemblies with similar errors. Somehow the files are locked or at least ASP.NET thinks they are.
It takes re-copying files (first impulse right? Must have screwed up the upload somehow!), a restart or editing of Web.Config to get the app back up and running. However on several occasions I've even restarted and not been able to get the assemblies to work. This even though the app runs locally. In that case I ended up copying the assemblies a couple more times (without changes mind you) and eventually it took.
It certainly looks like ASP.NET is somehow caching an invalid assembly (or all of them) and not letting them go after the upload is complete. In that case I get the dependency error, but no notice that the process cannot access a file. No secondary error message.
This is a new behavior for me. The uploads are relatively small (about 500k total) so the upload is pretty quick usually and I've been donig these sort of live updates forever. Even so I often used to get failures while files were copying but never once the files were on the server. This seems to be common now and it's thrown a small kink in my typical update routine. <shrug>
So over the last couple of days I started using App_Offline.htm to put the application on hold when updating assemblies, which is a bit of a hassle. In case you don't know about App_Offline.htm: It's a file you can drop into the root of your ASP.NET Virtual which causes ASP.NET to basically hold requests and show the content of this HTML page. ASP.NET displays the content of this file - oddly as text and not HTML - for any URL that would normally access an ASP.NET based URL.
I've never been enamored with this approach of having to have an external file that you either have to copy or rename on the server which is a bit annoying to automate. It'd be nicer if there was some mechanism to do this from within ASP.NET so it can be driven from within an application, but I suppose it makes sense: The idea is that no .NET assemblies should be loaded while App_Offline.htm is in place. If the idea is to make a clean update App_Offline.htm is the only way short of shutting down the Virtual Application or Web Server.
Since I've used the update with App_Offline.htm I've had no more problems as expected. I manage this process through my FTP upload process (which I usually do manually since I tend to update only a few files at a time rather than doing a full file dump). So my normal process is to logon jump to bin and update my assemblies, then update any pages that need to be updated.
With App_Offline.htm I keep the page in the site root and I rename it over FTP as needed. Rename to make it active, then copy all assemblies, then rename it back to something else.
What about you? How are you managing small updates to live sites? Have you seen the kind of issues i've mentioned above and have they gotten more pronounced recently (maybe something's changed in the runtimes?). And how do you manage your file updates and if you use App_Offline.htm how do you use it?