Question: ***tl;dr:*** **Menu from MvcSiteMapProvider sometimes fails to render itself after an application comes back online, even though the code runs and the menu renders after a page refresh.**

I am using the MvcSiteMapProvider in an ASP.NET MVC 3 project, and occasionally after switching the app from offline to online (by inserting a an `App_Offline.htm` file into the server's root and removing it) the menu will not render anything until the page is refreshed. 

I am using a custom DynamicNodeProvider to query out menu items from a database, and then render the menu. While debugging, I can see that this code is indeed running before the page loads, but no menu is rendered on the page. I have the cache set to several hours, and am using a custom cache key to allow invalidation after certain actions.

Unfortunately I cannot get this error to reproduce consistently. I *can* however get it to reproduce *more frequently* if I add a sleep at the top of the DynamicNodeProvider--it will fail about 60-70% of the time with a sleep of 30+ seconds. My best guess so far is that it has to do with the caching mechanism because setting my cache duration to 0 *seems* to make it so that there is no problem, and the menu always pops up. However, it's difficult to say for sure, as the problem is difficult to pin down. Leaving it at 0 wouldn't be an acceptable solution because of the performance drag.

What could be the root cause of this problem? Has anyone seen this behavior before or have a workaround?

Answer: 
MvcSiteMapProvider is bitten by the ASP.NET SiteMapProvider's threading model from time to time, especially when having larger sitemap definitions. Currently there's no workaround for this behaviour, but I'm planning on doing a rewrite (and ditching the ASP.NET SiteMapProvider dependency) to make it more stable under heavy conditions.
MvcSiteMapProvider v4 has been released, and is [available on NuGet](http://www.nuget.org/packages?q=mvcsitemapprovider&prerelease=&sortOrder=package-download-count). 

It uses its own cache mechanism that is both [more configurable](http://www.shiningtreasures.com/post/2013/08/11/mvcsitemapprovider-4-cache-configuration) and [more extensible](http://www.shiningtreasures.com/post/2013/08/13/mvcsitemapprovider-4-extending-the-cache) than it was previously. So far in v4 there have been no reports of menus disappearing or other weird first-request-only issues.