ASP.NET MVC缓存通过认证而异 [英] ASP.NET MVC Caching vary by authentication

查看:82
本文介绍了ASP.NET MVC缓存通过认证而异的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对我的使用ASP.NET preVIEW 5(即将升级至Beta版)与LINQ2SQL最近推出微小的webapp <​​/A>

I'm using ASP.NET Preview 5 (will upgrade soon to Beta) with LINQ2SQL on my recently launched tiny webapp.

我很自豪我的工作,直到Silverlight.net第一页功能它,它开始接受游客的多丑数。

I was so proud of my work until Silverlight.net featured it on the first page and it started receiving a more than humble number of visitors.

出于某种原因,用户有时会收到指定的转换无效的LINQ2SQL抛出 - 这是因为未经验证的用户作为Guest用户处理,控制器加载有关用户的客户信息,每一击

For some reason, users are sometimes getting "Specified cast invalid" thrown by the LINQ2SQL - this is because unauthenticated users are handled as a "Guest" user, and the Controller is loading information about the user "Guest" for each hit.

在第一页,有一个欢迎[用户名]在顶部可使用的甜甜圈缓存

In the first page, there is a "Welcome [USERNAME]" on the top which can be easily cached using Donut Caching.

然而,中间下来,还有一个什么是Dudlers.com模块,它应该只显示给未授权的用户,并只显示身份验证的用户另一个关于你块。这些块太复杂使用甜甜圈缓存缓存;他们实在是太不同了,它会很凌乱。

However, down in the middle, there is a "What is Dudlers.com" block which should only be shown to unauthenticated users, and another "About You" block which should only be shown to authenticated users. These blocks are too complicated to be cached using Donut Caching; they are way too different, it will be very messy.

我想通过根据用户的认证状态缓存的第一个。因此,未经验证的用户(不用说,大多数)获得客人缓存的页面,以及其他身份验证的用户显示一个新的非缓存页面。

I would like to cache the first by depending on the authentication status of the user. So unauthenticated users (needless to say, the majority) get the "Guest" cached page, and other authenticated users are shown a fresh non-cached page.

有没有指定缓存由认证不同的选项?就像是:
[的OutputCache(VaryBy =身份验证)]

Is there an option to specify caching varied by authentication? something like: [OutputCache(VaryBy = Authentication)]

还是有另一种non-ASP.NET MVC解决方案? (也许是调整MS SQL)

Or is there another non-ASP.NET MVC solution? (perhaps tuning MS SQL)

我希望我的问题是清楚的。
我在同一专用服务器上运行Windows 2003和MS SQL 2005前preSS。

I hope my question is clear. I'm running Windows 2003 and MS SQL 2005 Express on the same dedicated server.

感谢您!

推荐答案

您不必使用甜甜圈缓存机制。 ASP.NET有<$ ​​C $ C> VaryByCustom是选项,允许你来决定如何改变缓存。

You don't have to use the donut caching mechanism. ASP.NET has the VaryByCustom option, that allows you to determine how to vary the caching.

检查了这一点的详细信息:<一href=\"http://aspadvice.com/blogs/ssmith/archive/2007/10/29/VaryByCustom-Caching-By-User.aspx\">http://aspadvice.com/blogs/ssmith/archive/2007/10/29/VaryByCustom-Caching-By-User.aspx

Check this out for more info: http://aspadvice.com/blogs/ssmith/archive/2007/10/29/VaryByCustom-Caching-By-User.aspx

应该能正常运行ASP.NET MVC的。

Should work fine for ASP.NET MVC.

这篇关于ASP.NET MVC缓存通过认证而异的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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