samedi 19 décembre 2020

Accessing session data from a layout

In my ASP.NET MVC solution I have a number of services.

One of them, SessionService, is used to access the currently selected region and time span.

I want to display those in a layout used to decorate views. What is the best design approach to access those values which are stored in the SessionService?

Right now I'm thinking about using calling a ChildAction from the layout which in turn calls the session service:

_Layout -> aController.ChildAction() -> SessionService.GetRegion()

Is it a good approach or can you recommend anything better?

Aucun commentaire:

Enregistrer un commentaire