OnActionExecuted获取状态码 [英] OnActionExecuted get status code
本文介绍了OnActionExecuted获取状态码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以通过不使用会话变量的方式从OnActionExecuted
的MVC操作中获取HTTP状态代码?
Is there a way to get the HTTP status code from MVC action from OnActionExecuted
, without using the session variables?
推荐答案
有几种访问方法.主要通过从ControllerContext
There are a few ways to access it. Mainly via the ActionExecutedContext
which inherits from ControllerContext
protected override void OnActionExecuted(ActionExecutedContext filterContext) {
var statusCode = filterContext.HttpContext.Response.StatusCode;
}
这篇关于OnActionExecuted获取状态码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文