问题描述
什么是在一个异步方法的vNext应用程序中使用以下的正确方法:
What is the correct way of using the following in a vNext application on an async method:
[OutputCache(NoStore = true, Duration = 0, VaryByParam = "*")]
我看到它是System.Web.Caching的一部分,但我可以补充一点,唯一的地方,将在aspnet50 - 我project.json文件> frameworkAssemblies部分,这是不正确
I see it is part of System.Web.Caching, but the only place I could add that would be in the aspnet50 -> frameworkAssemblies section of my project.json file, which is incorrect.
推荐答案
更新结果
由于AndersNS是那种指出,这将是RC1提供最有可能的:。
要简单地没有的OutputCache
或等值 ASP.NET 5
目前
To put it simply there's no OutputCache
or equivalent in ASP.NET 5
currently.
不过,请注意,的OutputCache
只是一个与会谈到一个缓存提供最低逻辑属性。您可以轻松地实现自己的这种属性
,使用内存高速缓存
为例。或者你可以使用第三方解决方案。
However, please note that OutputCache
is just an attribute with minimal logic that talks to a cache provider. You can easily implement your own such attribute
, using Memory Cache
for example. Or you can use third party solutions.
我相信,当 ASP.NET 5
将船将有大量的解决方案市场上的。而且我敢肯定,我们将有一个正式的的OutputCache
等同了。
I am sure that when ASP.NET 5
will ship there will be plenty of solutions out on the market. And I'm quite sure that we will have an official OutputCache
equivalent too.
下面是基本的的MemoryCache
使用的情况下,有人认为它有用
Here's the basic MemoryCache
usage in case someone finds it useful
MemoryCache cache = MemoryCache.Default;
string cacheName = "MyCache";
if (cache.Contains(cacheName) == false || cache[cacheName] == null)
{
var data = ... get data
cache.Set(cacheName, data, new CacheItemPolicy() { SlidingExpiration = DateTime.Now.AddDays(1).TimeOfDay });
}
return cache[cacheName];
这篇关于我该如何申请一个方法的OutputCache属性在vNext项目呢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!