开发者

VirtualPathProvider on IIS 6 does not handle file stream caching correctly

I am working on a framework where .aspx and .master pages are embedded in an assembly, using VirtualPathProvider to route a url to a specific embedded resource.

Sample url: /_framework.aspx/mypage.aspx (which uses /_framework.aspx/mymaster.master)

  • _framework.aspx will make IIS6 route the request through ASP.NET framework
  • everything after the .aspx is treated as a PathInfo in the .NET framework

In Visual Studio 2008 web server, the virtualPath is correctly: /_framework.aspx/mypage.aspx but开发者_StackOverflow社区 in IIS6 the virtualPath is: /_framework.aspx

If I request two files: /_framework.aspx/file1.css and /_framework.aspx/file2.css the file2 will have the same content as file1.

I suspect that IIS6 considers the file path (_framework.aspx) and caches the file stream which is returned from the assembly, thus treating both urls as the same file.

Temporary solution:

I've implemented a CacheDependency class like this

class ImmediateExpiryCacheDependency : System.Web.Caching.CacheDependency
{
    public ImmediateExpiryCacheDependency()
    {
        base.NotifyDependencyChanged(null, null);
    }
}

It now expires the file stream cache, but doens't work with master pages, I guess because it is requested before the cache is expired through NotifyDependencyChanged.

Needed solution:

If I returned null in GetCacheDependency, IIS6 doesn't expire the file immediately. What is the correct way to immediately expire a file or disable the caching entirely. Even better, I would like to correct the way that IIS6 deals with the url, since the caching is actually good, if it would use the full file url.


Through my work in the ASP.NET Development Web Server, I had come to conclude that the correct FilePath would include the PathInfo, but I understand now that the IIS implementation is correct.

I changed my code so that ASP.NET files (aspx, ashx) would have a path such as /_framework/Default.aspx (since these files will be routed without special configuration) with a master page path such as /_framework/Site.master (since this is routed internally in the ASP.NET engine) and with image resources with a path /_framework.ashx/image.gif (since the .ashx will be routed to the ASP.NET engine, from where I will then use a kind of StaticFileHandler).

This way, all pages and resources can reside and remain entirely in the assembly :-)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜