views:

50

answers:

1

Hi,

How do I store a variable or object application wide in ASP.net MVC. In regular ASP, you had the Application object, and in ASP.net too apparently.

I'm using ASP.net MVC 2.

Thanks!

Yvan

+1  A: 

In a controller you should be able to do this:

this.HttpContext.Application["foo"] = "bar";
jwsample
For testability I'd be inclined to interface out this call to remove the dependency on HttpContext within the controller.
Daz Lewis
ASP.NET MVC relies on ASP.NET. so you can use almost any ASP.NET Feature.
Arthur