ASP.NET MVC OutputCache不适用于根URI

Mor*_*eng 11 asp.net-mvc action outputcache controller

我正在学习ASP.NET MVC并且被一个问题所困扰.

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

[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();
    }
}
Run Code Online (Sandbox Code Playgroud)

经过几分钟的尝试,我发现这是由于我访问动作的方式.如果我通过" http:// localhost:3573 / " 访问它,则outputcache不起作用.但是,如果我使用" http:// localhost:3575/Home/Index " 访问它,则outputcache可以正常工作.

任何人都知道任何解决方法,使默认的控制器 - 动作outputcacheable?

谢谢.

Eil*_*lon 7

我认为这是ASP.NET MVC中的一个错误.我们已将问题记录在我们的数据库中,并将调查此问题的修复程序.

谢谢,艾伦