开发者

MVC3 HttpStatusCodeResult Not working in OnActionExecuted

I have the following code which uses the new MVC3 HttpStatusCodeResult:

  protected override void OnActionExecuted(ActionExec开发者_开发百科utedContext filterContext) {
        base.OnActionExecuted(filterContext);
        filterContext.Result = new HttpStatusCodeResult(304, "Not Modified");
  }

I am still getting a 200OK and I can't figure out why. Please advise.


Works for me:

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

And the result is what we would expect:

MVC3 HttpStatusCodeResult Not working in OnActionExecuted

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜