我有以下代码使用新的MVC3 HttpStatusCodeResult:

  protected override void OnActionExecuted(ActionExecutedContext filterContext) {
        base.OnActionExecuted(filterContext);
        filterContext.Result = new HttpStatusCodeResult(304, "Not Modified");
  }

我还在拿200块,我不知道为什么。请告知。

最佳答案

对我有用:

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();
    }
}

结果就是我们所期望的:

关于c# - MVC3 HttpStatusCodeResult在OnActionExecuted中不起作用,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/5107632/

10-10 13:05