Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OnActionExecuted get status code

Is there a way to get the HTTP status code from MVC action from OnActionExecuted, without using the session variables?

like image 652
Brian Avatar asked Feb 24 '17 16:02

Brian


1 Answers

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;
}
like image 66
Nkosi Avatar answered Oct 12 '22 10:10

Nkosi