Does a child action share the same ViewBag with its “parents” action?

Child actions follow a different controller/model/view lifecycle than parent actions. As a result they do not share ViewData/ViewBag. If you want to pass parameters to a child action from the parent you could do this:

@Html.Action("Child", new { message = ViewBag.Message })

and in the child action:

public ActionResult Child(string message)
{
    ...
}

Leave a Comment