我有以下代码使用新的MVC3 HttpStatusCodeResult:
protected override void OnActionExecuted(ActionExecutedContext filterContext) {
base.OnActionExecuted(filterContext);
filterContext.Result = new HttpStatusCodeResult(304, "Not Modified");
}
我仍然得到200OK,我无法弄清楚为什么。请指教。
答案 0 :(得分:7)
适合我:
public class HomeController : Controller
{
protected override void OnActionExecuted(ActionExecutedContext filterContext)
{
base.OnActionExecuted(filterContext);
filterContext.Result = new HttpStatusCodeResult(304, "Not Modified");
}
public ActionResult Index()
{
return View();
}
}
结果就是我们所期望的: