PageData is part of the
PageContext. When Razor renders a view it automatically combines it with the
_ViewStart page and a Layout page. While it does this, it passes
PageContext around so the same
PageData is available to all 3 views.
Unfortunately, when it gets to partial views, the
Html.Partial/RenderPartial both work using
HtmlHelper which only passes a model (which can be replaced by explicitly providing a second argument) and
ViewData which is part of
ViewContext. That's why partial views never see PageData from the view that renders them.
If you want to make the culture available in partial views, you can put it into
ViewData instead. The only quirk here is that while it's available as a property inside views, layouts and partial pages, in the
_ViewStart page you have to access it through the
Layout = "~/Views/Shared/_Layout.cshtml";
var cultureRoute = ViewContext.RouteData.Values["lang"].ToString();
ViewContext.ViewData["culture"] = new System.Globalization.CultureInfo(cultureRoute);
Then just use ViewData instead of PageData everywhere else:
var culture = ViewData["culture"];
This blog post has some more details on how Razor uses
PageContext while rendering pages.