Home PageData value returning null inside partial view
Reply: 0

PageData value returning null inside partial view

Bassie Published in 2017-09-14 07:32:46Z

I have this code in _ViewStart.cshtml:

    Layout = "~/Views/Shared/_Layout.cshtml";

    var cultureRoute = ViewContext.RouteData.Values["lang"].ToString();
    PageData["culture"] = new System.Globalization.CultureInfo(cultureRoute);

And not having any problems retrieving culture in my views, including the partial _Layout view with this at the top of the page:

    var culture = @PageData["culture"];

However, after creating a new partial view, _Navbar, the exact same piece of code assigns culture to null when calling it from insde _Layout with


Why is that PageData variable no longer available?

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.368839 second(s) , Gzip On .

© 2016 Powered by cudou.com design MATCHINFO