ASP.NET MVC OutputCache不适用于根URI [英] ASP.NET MVC OutputCache doesn't work for root URI
问题描述
在HomeController中,Index动作有OutputCache属性,但似乎不工作。
[HandleError]
public class HomeController:Controller
{
[OutputCache = 5,VaryByParam =none)]
public ActionResult Index()
{
ViewData [Title] =Home Page+ DateTime.Now;
ViewData [Message] =欢迎使用ASP.NET MVC!+ DateTime.Now;
return View();
}
}
尝试了几分钟后,是由于我访问操作的方式。如果我通过 http:// localhost:3573 / 访问它,则outputcache不工作。但是,如果我使用 http:// localhost:3575 / Home / Index 访问它,则输出缓存工作。
任何人都知道任何解决方法,使默认的控制器动作outputcacheable。
p>
我认为这是ASP.NET MVC中的一个错误。我们已将问题记录在我们的数据库中,并会调查此问题的修正。
谢谢,
Eilon
I'm learning ASP.NET MVC and bugged by one issue.
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();
}
}
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?
Thanks.
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.
Thanks, Eilon
这篇关于ASP.NET MVC OutputCache不适用于根URI的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!