ASP.NET MVC5 Access ViewBag from layout?
I would suggest that you have an action method, which the layout uses, that passes the data you need. For example
public class ControllerName : Controller
{
public ActionMethod GetData()
{
return Content("Some data"); // Of whatever you need to return.
}
}
then in the layout and the view you can call
@Html.Action("GetData", "ControllerName")