标签: output-caching

如何关闭整个ASP.NET MVC 3网站的缓存?

就像问题所说的那样,我想知道是否可以关闭整个站点的所有控制器和操作的缓存.谢谢!

caching output-caching asp.net-mvc-3

9
推荐指数
2
解决办法
9084
查看次数

MVC4在配置文件中查看缓存持续时间?

有没有在MVC4 .net页面的web.config中设置缓存的持续时间?我有 :

[OutputCache(Duration = Convert.ToInt32(ConfigurationManager.AppSettings["cache.eventPage"]), VaryByParam = "Id")]
public ActionResult....
Run Code Online (Sandbox Code Playgroud)

哪个不会编译,因为

属性参数必须是属性参数类型的常量表达式,typeof表达式或数组创建表达式

我们有非常灵活的流量,并且希望能够在推出新版本的情况下非常快速地更改此值.这可能吗?

asp.net caching output-caching asp.net-mvc-4

7
推荐指数
1
解决办法
2079
查看次数

你能否强制删除asp.net-mvc中的(page和partialView)OutputCache

我想要一个简单的方法来清除我的asp.net-mvc网站上的缓存页面.

我有昂贵的数据库操作,所以我经常使用输出缓存来使网站运行得更快.我的代码看起来像这样:

    [OutputCache(Duration = 30000)]
    public ActionResult Index()
    {
         return View();
    }

    [OutputCache(Duration = 30000, VaryByParam = "*")]
    public ActionResult GetData(MyParams myParams)
    {
        return PartialView("MyView", GetVM(myParams));
    }
Run Code Online (Sandbox Code Playgroud)

当我想明确清除此缓存(无论现有的缓存持续时间)时,有一些时候(当出现问题时)

无论如何,有完整和部分页面Outputcaching删除缓存页面并运行完整的代码?

注意:我看到这个问题已经在这里围绕asp.net一般问过,但我没看到asp.net-mvc特定的解决方案

我试过这个,但它似乎不起作用:

 public ActionResult ClearCache()
 {
      this.HttpContext.Response.RemoveOutputCacheItem("/MyController/Index.aspx");
      this.HttpContext.Response.RemoveOutputCacheItem("/MyController/MyView.ascx");
 }
Run Code Online (Sandbox Code Playgroud)

c# asp.net-mvc outputcache output-caching

6
推荐指数
1
解决办法
4216
查看次数

如何在输出缓存中使用动态持续时间值?

我正在使用ASP.NET MVC3.
我在控制器方法上使用了输出缓存.

   [OutputCache(Duration = 3660, VaryByParam = "none")]
   public ActionResult Index()
   {
       some code;
       return View();
   }
Run Code Online (Sandbox Code Playgroud)

我想在输出缓存中使用一些静态变量或其他东西来设置动态持续时间.

我怎样才能做到这一点?

output-caching asp.net-mvc-3

6
推荐指数
1
解决办法
1893
查看次数

如何使用具有可变持续时间值的[OutputCache(Duration = 2000)]并重置服务器缓存

我有下面的代码,并希望Duration[OutputCache(Duration = 10)]行有一个变量的值,这样我可以从阅读DB或从List收藏.

而且我希望能够立即复位服务器缓存中,当Duration发生了变化.

如何在更改时更改Duration缓存HTML数据Duration?这是我的代码.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace Cache_Example.Controllers
{
    public class HomeController : Controller
    {

        // GET: Home
       // [OutputCache(Duration = 10)]
        public ActionResult Index()
        {
            return View();
        }

        [OutputCache(Duration = 10)]
        public ActionResult ShowDate()
        {
            return PartialView();
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

c# asp.net-mvc outputcache output-caching asp.net-mvc-4

5
推荐指数
1
解决办法
1160
查看次数

无法在WebConfig文件中设置outputCacheSettings

我试图在我的网站中实现输出缓存当我尝试添加时

    <outputCacheSettings>
    <outputCacheProfiles>
        <add name="TwoDay" duration="43200" />
    </outputCacheProfiles>
</outputCacheSettings>
Run Code Online (Sandbox Code Playgroud)

这对我的webconfig文件引发了错误

    The configuration section 'outputCacheSettings' cannot be read because it is missing a section declaration
Run Code Online (Sandbox Code Playgroud)

我在里面添加了上面的代码

<configuration>
Run Code Online (Sandbox Code Playgroud)

webconfig中的部分.谁能告诉我我做错了什么?

asp.net web-config output-caching

2
推荐指数
1
解决办法
2146
查看次数