Accessing an access session variable from an ASP.NET MVC3 RAZOR layout page

I want to access a session variable from my main layout page, but you don't have a model on the layout page, so how do I access this variable?

0
source share
2 answers
@{var sessionvar = Session["myVar"] as FooType;}
+4
source

You must transfer this logic to the child action and invoke the child action from the main page with @Html.Action(...).

To answer a question, use a property Session.

+1
source

Source: https://habr.com/ru/post/1626860/


All Articles