在ASP.NET MVC 3的OutputCache行为 [英] OutputCache behavior in ASP.NET MVC 3

查看:164
本文介绍了在ASP.NET MVC 3的OutputCache行为的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚测试输出缓存在ASP.NET MVC 3的RC版本。

I was just testing Output Caching in the RC build of ASP.NET MVC 3.

不知何故,它没有履行的财产的VaryByParam(或者说,我不知道我的理解是怎么回事):

Somehow, it is not honoring the VaryByParam property (or rather, I am not sure I understand what is going on):

public ActionResult View(UserViewCommand command) {

下面,UserViewCommand有一个属性叫做塞用来查找从数据库中的用户。

Here, UserViewCommand has a property called slug which is used to look up a User from the database.

这是我的OutputCache声明:

This is my OutputCache declaration:

[HttpGet, OutputCache(Duration = 2000, VaryByParam = "None")]

然而,当我尝试使用不同的鼻涕虫的值(由manupulating的URL)打Action方法,而不是提供错误的数据(我试图通过设计给力),它是不是调用的操作方法。

However, when I try and hit the Action method using different 'slug' values (by manupulating the URL), instead of serving wrong data (which I am trying to force by design), it is instead invoking the action method.

因此​​,例如(在调用的顺序)

So for example (in order of invocation)

/用户/视图/ ABC - >调用处理法塞= ABC
/用户/视图/ ABC - >操作方法不调用
/用户/视图/ XYZ - >再次调用处理法塞= XYZ!是不是不应该出来的缓存,因为的VaryByParam =无?

/user/view/abc -> Invokes action method with slug = abc /user/view/abc -> Action method not invoked /user/view/xyz -> Invokes action method again with slug = xyz! Was it not supposed to come out of the cache because VaryByParam = none?

此外,什么是OutputCaching在这种情况下推荐的方法是什么? (上面的例子)

Also, what is the recommended way of OutputCaching in such a situation? (example above)

推荐答案

只想添加此信息,以便人们进行搜索的帮助:

Just wanted to add this information so that people searching are helped:

本的OutputCache行为已更改是在最新发布的预期(ASP.NET MVC 3 RC 2):

The OutputCache behavior has been changed to be 'as expected' in the latest release (ASP.NET MVC 3 RC 2):

<一个href=\"http://weblogs.asp.net/scottgu/archive/2010/12/10/announcing-asp-net-mvc-3-release-candidate-2.aspx\">http://weblogs.asp.net/scottgu/archive/2010/12/10/announcing-asp-net-mvc-3-release-candidate-2.aspx

要走的路ASP.NET MVC团队(和主谷)!你们都是真棒!

Way to go ASP.NET MVC team (and Master Gu)! You all are awesome!

这篇关于在ASP.NET MVC 3的OutputCache行为的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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