I'm writing an Asp.net MVC application (my first MVC app). I need to pass data to the _Layout view to customize the header and footer on my pages - which user is logged in, if they have any notifications, etc. The _Layout page always needs this information, but the child pages do not.
How should I pass this data to the view? Can I create a LoggedInUser
property that the view can access, in the same way there is a Model
and ViewBag
? LoggedInUser
could be populated by the base controller class.
Or is there a better way to implement this?