Pages

Thursday, 21 May 2009

Session Availability in ASP.Net MVC

We are in the process of porting one of our Web Forms apps to ASP.Net MVC. This is just something we stumbled upon...

this.Session is null in a Controller's constructor.

Not a huge issue as you can use a Lazy Loading Pattern to circumvent it. It does raise the question of 'why?' though. The MVC (or Routing) framework is responsible for newing-up your Controllers to handle requests. Why couldn't Session be spun up prior to this?

No comments:

Post a Comment