ASP.NET MVC OutputCache 不适用于根 URI [英] ASP.NET MVC OutputCache doesn't work for root URI

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

问题描述

我正在学习 ASP.NET MVC,但被一个问题困扰.

I'm learning ASP.NET MVC and bugged by one issue.

在 HomeController 中,Index action 有 OutputCache 属性,但似乎不起作用.

In the HomeController, the Index action has OutputCache attribute, but it seems doesn't work.

[HandleError]
public class HomeController : Controller
{
    [OutputCache(Duration=5, VaryByParam="none")]
    public ActionResult Index()
    {
        ViewData["Title"] = "Home Page" + DateTime.Now;
        ViewData["Message"] = "Welcome to ASP.NET MVC! " + DateTime.Now;

        return View();
    }
}

尝试了好几分钟后,我发现这是由于我访问操作的方式造成的.如果我通过http://localhost:3573/"访问它,输出缓存不起作用.但是,如果我使用http://localhost:3575/Home/Index"访问它,则输出缓存有效.

After quite a few minutes trying, I found that it is due to the way I access the action. If I access it through "http://localhost:3573/", the outputcache doesn't work. However, if I access it with "http://localhost:3575/Home/Index", the outputcache works.

有人知道使默认控制器操作输出可缓存的任何解决方法吗?

Anybody know any workaround to make the default controller-action outputcacheable?

谢谢.

推荐答案

我认为这是 ASP.NET MVC 中的一个错误.我们已将该问题记录在我们的数据库中,并将调查解决此问题的方法.

I think this is a bug in ASP.NET MVC. We have logged the issue in our database and will investigate a fix for this issue.

谢谢,艾隆

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

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