开发者

MVC3 HttpStatusCodeResult Not working in OnActionExecuted

开发者 https://www.devze.com 2023-02-13 09:48 出处:网络
I have the following code which uses the new MVC3 HttpStatusCodeResult: protected override void OnActionExecuted(ActionExec开发者_开发百科utedContext filterContext) {

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

精彩评论

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