Is it possible to get the Action result type (ViewResult, JsonResult, etc) from an instance of ControllerContext?
Is it possible to get the Action result type ( ViewResult , JsonResult ,
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
No, that’s not possible. The controller runs much earlier than any ActionResults. But if you are writing an ActionFilter you could get that information from the
filterContextusing its Result property.For example:
Bear in mind that this makes sense only once the controller action has finished executing, a.k.a only inside
OnActionExecuted,OnResultExecutingandOnResultExecuted. It makes no sense to be attempting to verify what result did the controller action returned before this action has finished executing.