Кажется, что фильтр выходного кэша не применяется, когда действие контроллера возвращает результат RedirectResult.
Ниже описано, как воспроизвести проблему с веб-приложением ASP.Net MVC3 по умолчанию для Интернета:
В Web.config:
<system.web>
<caching>
<outputCache enableOutputCache="true"></outputCache>
<outputCacheSettings>
<outputCacheProfiles>
<add name="ShortTime" enabled="true" duration="300" noStore="false" />
</outputCacheProfiles>
</outputCacheSettings>
</caching> ...
В HomeController.cs:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace MvcOutputCacheRedir.Controllers
{
public class HomeController : Controller
{
[OutputCache(CacheProfile = "ShortTime")]
public ActionResult Index()
{
ViewBag.Message = "Welcome to ASP.NET MVC!";
return View();
}
[OutputCache(CacheProfile = "ShortTime")]
public ActionResult About()
{
// Output cache works as expected
// return View();
// Output cache has no effect
return Redirect("Index");
}
}
}
Я не могу найти это поведение, указанное где-либо ... это нормально?Если да, то какой обходной путь?