web-applicationssessionmvp

MVP - Should the Presenter use Session?


I am using the Model-View-Presenter pattern for a web page. Should the presenter be aware of Session or should only the view be aware of it?

I guess what I am getting at is that concepts like Session are very related to the architecture of the view so should they be limited to use by the view? Otherwise what would happen if I wanted to reuse the presenter on a similar page on a different architecture (or do I not need to worry about that unless I have plans to do so)?


Solution

  • I am doing something like this in my MVP Implementation I inject an ICookieManager, ISessionManager, ICacheManager, IConfigurationManager, IRedirector into my presenter which are implemented by classes that wrap the functionality for this.

    This allows for a presenter where you can inject mocked versions of these in and you have no direct dependancies on the asp.net runtime in your presenter so it makes testing easier.

    Cheers