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.
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?
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?
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.
Oh well.
jbeall
Participant
813 Points
274 Posts
VirtualPathProvider and caching compiled code--I'm getting code that is cached for too long
Jul 14, 2008 06:16 PM|LINK
Hi There,
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: http://msdn2.microsoft.com/en-us/library/system.web.hosting.virtualpathprovider.getcachedependency.aspx".
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?
-Josh
jbeall
Participant
813 Points
274 Posts
Re: VirtualPathProvider and caching compiled code--I'm getting code that is cached for too long
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?
-Josh
chrisaswain
Member
8 Points
15 Posts
Re: VirtualPathProvider and caching compiled code--I'm getting code that is cached for too long
Sep 24, 2009 05:37 PM|LINK
Did you ever make anymore progress on figuring this out? I'm having the same issue.
virtualpathprovider
downatone
Member
4 Points
14 Posts
Re: VirtualPathProvider and caching compiled code--I'm getting code that is cached for too long
Oct 05, 2009 07:56 PM|LINK
I'm also having the same issue - any luck?
jbeall
Participant
813 Points
274 Posts
Re: VirtualPathProvider and caching compiled code--I'm getting code that is cached for too long
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. Oh well.
-Josh