Detect View or PartialView in controller

asp.net-mvc

Solution

Check

ControllerContext.IsChildAction

in your action method, or

filterContext.IsChildAction

in OnActionExecuted

Problem

In a controller can I detect if I'm "controlling" a View or a partial view? I have a shared controller that sits between any controller and `Controller`, there are things I would only like to happen if its a View rather than a partial view. Ideally in `protected override ViewResult View(...`

Original source