Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Oct 05, 2009 08:17 PM by jbeall
Jul 14, 2008 06:16 PM|LINK
We implemented a basic VirtualPathProvider to allow our multiple sites to share from a single set of MasterFiles.
It's working alright, but one of the problems we've run up against is that when we change the code file for any of the master files, ASP.NET does not pick up on this change.
According to this KB article, "The virtual provider exposes an API that is named GetCacheDependency that is used to help cache virtual resources. We can invalidate the cache when any of the files become
invalid. For more information, visit the following MSDN Web site:
That sounds exactly like what I need. However, when I review the documentation for GetCacheDependency, I'm not clear on exactly what I'm suppose to do in my implementation. I tried the example implementation from MSDN, but it results in throwing an error
that says "Absolute path information is required".
So, can anyone fill me in? How do I get ASP.NET to recompile the master pages when the code file changes?
Jul 15, 2008 03:05 PM|LINK
B y trial and error, I've observed the following things must be true in order to get content fetched from a VirtualPathProvider to be "fresh".
1) GetCacheDependency must return null (Nothing in VB.NET)
2) GetFileHash must return a different value than the last hash for the file in question
I don't totally understand how ASP.NET handles all the caching dependencies. For instance, why does it request file hashes for some files but not others (it seems to *never* request the hashes for your code files, only aspx and .master files, and I assume
.ascx files as well).
I have a feeling this is not the "right" way. In particular, there must be a way to return a valid CacheDependency object?
Sep 24, 2009 05:37 PM|LINK
Did you ever make anymore progress on figuring this out? I'm having the same issue.
Oct 05, 2009 07:56 PM|LINK
I'm also having the same issue - any luck?
Oct 05, 2009 08:17 PM|LINK
No, I never did get this figured out (beyond what I outlined above).
In fact, we wound up abandoning the VirtualPathProvider class for the moment. I couldn't get the other developer on my team to buy in to it. :-) And he had some legitimate concerns about how well we really understood what was going on with the caching.