I am developing a website in Asp.net MVC. I pass the HttpContext to the Model from the Controller in the Model's constructor to get access to the Session so I can manipulate the Session variables. I am assuming that this is just a reference and won't incurr a huge performance penalty. I am keeping my controllers clean by doing this but I am wondering if there is a drawback that I am not aware of.
views:
54answers:
1
A:
I think your performance will be fine for small to medium sites. Just take the normal precautions of NOT using in-memory session state on the production server and monitoring the footprint.
From a code perspective, wrap access to the session object in your own class so it's abstracted and strongly typed. Then your model gets access to this class instead of direct access to the System.Web session object.
AndrewDotHay
2010-06-30 21:06:37