I'm overriding OnActionExecuting method in order to perform some checks before calling some controllers' methods and I was wondering if there was any way to read context.Result() value to check if it's equal to - for example - Status 401 Unauthorized or similar, in order to perform different actions on different status, like this...
public override void OnActionExecuting(ActionExecutingContext context) {
base.OnActionExecuting(context);
if (/*context.Result()==401*/)
{
//do things
}
else
{
//do other things
}
}
Is there any way to read context.Result()
value/status in order to use it inside an if() statement?
You can get and compare with
Response.StatusCode
: