简体   繁体   English

OnActionExecuted获取状态代码

[英]OnActionExecuted get status code

有没有办法从OnActionExecuted获取MVC操作的HTTP状态代码,而不使用会话变量?

There are a few ways to access it. 有几种方法可以访问它。 Mainly via the ActionExecutedContext which inherits from ControllerContext 主要通过继承自ControllerContextActionExecutedContext

protected override void OnActionExecuted(ActionExecutedContext filterContext) {
    var statusCode = filterContext.HttpContext.Response.StatusCode;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM