Geeks With Blogs
Mike Nichols - SonOfNun Technology If I were the captain on a big steamboat...
Say I have a Facade layer which sits just beneath my UI (in this case ASP.NET) layer. This, of course, provides the API for my controller (code-behind) classes to interact with my domain as well as encapsulating my Application Logic. I understand it is good to do some kind of Session management in this layer too, but I just don't get the best way to do this without directly referencing the Session object from HttpContext. This limits my Facade to being a Web-facing service layer, though, so that isn't gonna work. I don't want to store session variables in my code-behind because this seems to force me into putting biz rules in my ui layer : bad. Does anyone have a good resource or architecture they have used to have session management in layers beneath the UI this simply some kind of second-level caching? Anyone else come across this? Posted on Thursday, May 25, 2006 6:57 PM ASP.NET | Back to top

Comments on this post: ASP.NET architecture Session pattern anyone?

# re: ASP.NET architecture Session pattern anyone?
Requesting Gravatar...

Why not create an interface ISessionDataProvider .. then inject a WebSessionDataProvider that interacts with session into your facade layer ...

If you later used another methodology you would just have to define a ISessionDataProvider for it and inject it from the hosting code.

This will allow your UI to define the session management (and allow your facade layer to use it).

I probably won't remember to come back through but feel free to contact me through link aboce.


Greg Young
Left by Greg Young on May 25, 2006 9:01 PM

# re: ASP.NET architecture Session pattern anyone?
Requesting Gravatar...
Try the MS Enterprise Application Blocks.

Left by Mike Coleman on May 26, 2006 6:38 AM

# re: ASP.NET architecture Session pattern anyone?
Requesting Gravatar...
Thanks Greg & Coleman for your replies.
Coleman -I have used the Enterprise Library Cache in the past...I am using NHibernate for the current app i am working on and haven't thought much how I'd have those two work together. I assume you are proposing for me to store objects in teh EL cache in my facade layer and then fetch those out of my UI, yeah?
Greg - My only problem with using IoC to inject my session provider into my facade objects is the fact that all my Facades are Singleton objects (as recommended). As such I am not sure how I'd deal with the many threads keeping their own sessions in that layer. I may not understand very well the subject of threading, but it seems like a single instance of the Facade object would only allow a single Session object as well (unless I pass the Session object to the Facade object with each method call). I think I am sounding confuzed :)
BTW - I have read your posts in the past and have found them helpful.
THanks again.
Left by MIke Nichols on May 26, 2006 12:59 PM

Your comment:
 (will show your gravatar)

Copyright © Mike Nichols | Powered by: