views:

306

answers:

2

I regularly (every few days or so) publish my ASP.NET web project to the local web server.

But the weirdest thing keeps happening... a file called "app_offline.htm" keeps appearing, unbidden, in my web project!

I have deleted this file several times, it is not in source control, and AFAIK nobody else is tampering with the project. But practically every time I try to publish the project, my publish fails (Unable to add 'app_offline.htm' to the Web site. The file 'app_offline.htm' already exists in this Web site.Error: The operation could not be completed. Unspecified error), I go back to look at the project, and there it is again, large as life, and I suspect if it could it would be blowing raspberries at me. :p

Having read up a little about this file, I gather it's meant to be an easy way to take your app offline. But I didn't see anywhere that it's supposed to impose itself on you arbitrarily for no good reason.

So, where is this *&^%$#@%!! file coming from, and why does VS think I need it?

+2  A: 

By default the publish process places one in your destination directory but then deletes it when the publish process is done. Perhaps it is being prevented from deleting it when it tries to?

Here is an excerpt from the MSDN article here:

Before you copy application files, the Copy Web Site tool puts a file that is named App_offline.htm into the root directory of the target Web site. While the App_offline.htm file exists, any requests to the Web site are redirected to this file. The file displays a friendly message that tells clients that the Web site is being updated. When all Web site files have been copied, the Copy Web Site tool deletes the App_offline.htm file from the target Web site.

I'd guess that for some reason, there are two publish events somehow conflicting with each other?

The way I get around this is to use nant to build my solution and then copy just the stuff I want. I do indeed copy the app_offline file first, utilizing the feature, but then I manage when it gets copied and deleted.

Nick DeVore
+3  A: 

This is a .NET 2.0 "feature"

http://weblogs.asp.net/scottgu/archive/2005/10/06/426755.aspx

http://www.codeproject.com/KB/aspnet/app_offline.aspx

"The easiest way around this is to never publish directly to your server. You shouldn't anyway... Publish to a local folder then copy the site up"

Do you use Visual Studio? http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=102778

Albert
+1 Useful links, but the one at microsoft.com is broken.
Shaul
The microsoft link can be fixed if you just get rid of the .3 at the end.
Shaul
+answer credit - the MS link had the info I was looking for. Thanks!
Shaul
crap, sorry about that. fixed the link.
Albert