- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
当 Controller 操作返回 RedirectResult 结果时,输出缓存过滤器似乎不适用。
以下是如何重现 ASP.Net MVC3 默认 Internet Web 应用程序的问题:
在 Web.config 中:
<system.web>
<caching>
<outputCache enableOutputCache="true"></outputCache>
<outputCacheSettings>
<outputCacheProfiles>
<add name="ShortTime" enabled="true" duration="300" noStore="false" />
</outputCacheProfiles>
</outputCacheSettings>
</caching> ...
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");
}
}
}
最佳答案
这绝对是有意的行为。 OutputCacheAttribute 仅用于生成字符串的 ActionResults。事实上,如果你仔细研究一下(Reflector/ILSpy 是你的 friend ),你会特别看到:
string uniqueId = this.GetChildActionUniqueId(filterContext);
string text = this.ChildActionCacheInternal.Get(uniqueId, null) as string;
if (text != null)
{
filterContext.Result = new ContentResult
{
Content = text
};
return;
}
关于asp.net-mvc - OutputCache 不缓存 RedirectResult,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8013157/
当 Controller 操作返回 RedirectResult 结果时,输出缓存过滤器似乎不适用。 以下是如何重现 ASP.Net MVC3 默认 Internet Web 应用程序的问题: 在 W
我正在尝试使用 T4MVC 设置 filterContext.Result = new RedirectResult 我现有的通话是: filterContext.Result = new Redir
我们的一个 Azure Functions(运行 2.0)应该返回一个 RedirectResult(由外部 webhook 触发,进行一些处理并且应该重定向到网页)。 这在我们的测试环境中有效,但在
我正在开发一个完整的 web 应用程序,我正在使用 ASP.NET MVC 3 框架。我正在实现 ActionFilterAttribute 的子类. 我正在覆盖 OnActionExecuting方
当我这样重定向时 protected override void OnActionExecuting(ActionExecutingContext filterContext) { f
我是一名优秀的程序员,十分优秀!