我想在我的asp.net-mvc网站中缓存我的大多数数据库繁重的操作.在我的研究中,我发现了
但我觉得我还没有得到它.
我希望能够根据几个部分缓存我的POST请求.这些语句位于对象中.所以我想缓存以下请求的结果:
public ActionResult AdvancedSearch(SearchBag searchBag)
Run Code Online (Sandbox Code Playgroud)
其中searchBag是一个包含(一堆)可选搜索参数的对象.我的观点本身很轻(应该如此),但数据访问可能相当耗时,具体取决于搜索包中填写的字段.
我觉得我应该缓存数据层,而不是我的行为.
我怎么在OutputCache属性中使用VaryByParam?
我正在做一个ASP.NET MVC应用程序,我的一些Action方法和其他扩展方法需要访问用户数据.我用来获取用户的代码是:
this.currentUser = (CurrentUser)HttpContext.Session["CurrentUser"];
//and in the extension methods it's:
CurrentUser user = (CurrentUser)HttpContext.Current.Session["CurrentUser"];
Run Code Online (Sandbox Code Playgroud)
在很多我的控制器中,我的很多Action方法都分散了这一行.问题是这使得测试变得困难,并且看起来并不是非常"优雅".
谁能建议一个好的SOLID方法来解决这个问题?
谢谢
戴夫