I have an ASP.NET MVC 3 application with an action that uses both the RequireHttps
and OutputCache
attributes:
[RequireHttps]
[OutputCache(Duration = 14400, VaryByCustom = "CurrentUser"]
public ActionResult VersionB()
{
return View();
}
When I navigate to that page, I get redirected to HTTPS, as expected.
However, after that initial page load, I can still access the page via HTTP. If I remove the OutputCache
attribute, I can no longer access the page via HTTP.
It seems as if the OutputCache disregards HTTPS, thus allowing insecure access to the page. Is it even possible to cache an action that is served over HTTPS?
The
[RequireHttps]
attribute implementation is flawed and doesn't take into account caching.Here's a fix:
and then: