Im converting a webforms app to mvc 4. The app does a fair amount of processing in the master page codebehind to do stuff such as determine what the user can or cant see based on their role, display a version at the bottom of the page from the assembly, etc. All server side.
I get that the processing isnt in a codebehind, but in a controller with the data sent to the view. But its not clear to me how this is done in the _Layout.cshtml
Thanks very much
Something you might be able to do is to use a base controller and override the
OnActionExecutingmethod and then use theViewBagdynamic property to pass values to your_Layout.cshtmlYou’d need to extend this base controller with application controllers
Then in your
_Layout.cshtmlyou can access theViewBagproperty like so…