views:

54

answers:

1

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.

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