ASP.NET MVC 2的VirtualPathProvider的GetFile为每个请求,每次 [英] ASP.NET MVC 2 VirtualPathProvider GetFile every time for every request
问题描述
我已经实施了的VirtualPathProvider。该的VirtualPathProvider读取文件系统视图。
不过我的问题是的GetFile(字符串virtualPath)
不是为每个请求每次执行的方法。我认为这是关系到高速缓存,是不是?我想让每一个文件为每个请求的时间即可。因为对于一些情况下,在文件系统中的页将被修改,并且用户希望系统立即显示的更改。
感谢。
我找到了自己的解决方案在互联网上。
由于真正的 jbeall 回答关于2008年7月15日,11:05 AM。
http://forums.asp.net/t/1289756.aspx
在短词,覆盖下面的方法
-
GetCacheDependency
- 总是返回null -
GetFileHash
- 总是返回不同的值
这些修改后,为每个请求,MVC从源头直接获取文件。</ P>
I have implemented a VirtualPathProvider. The VirtualPathProvider reads the view from File system.
However my problem is the method GetFile(string virtualPath)
is not executed every time for every request. I think it is related to the caching, isn't it? What I want is getting file every time for every request. Because for some cases, the page in the file system will be modified and users want the system shows the changes immediately.
Thanks.
I found the solution myself on the internet.
Really thanks jbeall replied on 07-15-2008, 11:05 AM.
http://forums.asp.net/t/1289756.aspx
In short words, overrides the following methods
GetCacheDependency
- always return nullGetFileHash
- always return different value
After these modifications, for every request, MVC gets the file from source directly.
这篇关于ASP.NET MVC 2的VirtualPathProvider的GetFile为每个请求,每次的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!