11

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.

2
  • I'm seeing the same problem here. Commented Jan 16, 2009 at 18:54
  • any of you people using chrome? i've noticed some wierdness in chrome caching Commented Apr 2, 2009 at 22:20

3 Answers 3

7

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

Sign up to request clarification or add additional context in comments.

2 Comments

Will you also fix the bug where setting VaryByParam to "None" will emit the HTTP response header "Vary: *", which is the opposite of what should happen?
@Eilon I'm still seeing this still as an issue, have you any recommendations for caching a root uri? other than redirecting to /home ;)
1

using VarByParam="" seems to make it work

Comments

1

According to my contacts at Microsoft, the issue disappears entirely if you remove the Default.aspx file from the root of your site, or, if you absolutely need to have it, make sure you use the one that's provided with the latest version of ASP.NET MVC.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.