views:

408

answers:

3

I have a virtual path provider. Problem is its caching my files. Whenever I manually edit one of the aspx files it references the VPP doesn't pull in the new file, it continues to reuse the old file until I restart the site.

I've even over-rode the GetCacheDependency() in my VirtualPathProvider class:

    public override CacheDependency GetCacheDependency(string virtualPath, IEnumerable virtualPathDependencies, DateTime utcStart)
    {
        return null;
    }

Ideas?

A: 

Any ideas? Still have this problem.

A: 

Returning a null is essentially telling ASP.NET that you do not have any dependency - hence ASP.NET will not reload the item.

What you need is to return a valid dependency e.g.

 public override CacheDependency GetCacheDependency(string virtualPath, IEnumerable virtualPathDependencies, DateTime utcStart)
    {
        return new CacheDependency(getPhysicalFileName(virtualPath));
    }

A more correct approach is to make sure that you only handle your own cache dependencies (this is a schematic example) :

 public override CacheDependency GetCacheDependency(string virtualPath, IEnumerable virtualPathDependencies, DateTime utcStart)
    {
        if (isMyVirtualPath(virtualPath))
            return new CacheDependency(getPhysicalFileName(virtualPath));
        else
            return new Previous.GetCacheDependency(virtualPath, virtualPathDependencies, utcStart);
    }
Samir Seth
A: 

I think I'm having the same issue: http://stackoverflow.com/questions/2280041/virtualpathprovider-on-iis-6-does-not-handle-file-stream-caching-correctly

Did you find a solution?

It seems that my IIS6 crashes with my temporary solution :-(

Matthew Peterson