ASP.NET MVC 2的VirtualPathProvider的GetFile为每个请求,每次 [英] ASP.NET MVC 2 VirtualPathProvider GetFile every time for every request

查看:154
本文介绍了ASP.NET MVC 2的VirtualPathProvider的GetFile为每个请求,每次的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经实施了的VirtualPathProvider。该的VirtualPathProvider读取文件系统视图。

不过我的问题是的GetFile(字符串virtualPath)不是为每个请求每次执行的方法。我认为这是关系到高速缓存,是不是?我想让每一个文件为每个请求的时间即可。因为对于一些情况下,在文件系统中的页将被修改,并且用户希望系统立即显示的更改。

感谢。


解决方案

我找到了自己的解决方案在互联网上。

由于真正的 jbeall 回答关于2008年7月15日,11:05 AM。

http://forums.asp.net/t/1289756.aspx

在短词,覆盖下面的方法


  1. GetCacheDependency - 总是返回null

  2. 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

  1. GetCacheDependency - always return null
  2. GetFileHash - always return different value

After these modifications, for every request, MVC gets the file from source directly.

这篇关于ASP.NET MVC 2的VirtualPathProvider的GetFile为每个请求,每次的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆