Accessing Application object from controller
Posted on 2010-11-15
New to web development. Having a bit of "flow confusion".
I set an Application value in global.asax that identifies the environment (dev/test/prod).
I have a base controller that I want to expose a "CanUserEdit" property to be used by controllers, and also set an Application value for views to consume.
In my master page, I test "ViewData["CanUserEdit"]", which explodes because there is no such value.
I can't set the ViewData value in the base controller's constructor because there's no HttpContext at that point.
So, where can I hook into to set the ViewData value and how will this tie in with unit testing? I guess I'll need to be able to hand over a mock context for testing.