The problem was that I was setting the Application variable in Application_Start() of Global.asax. I was accessing this variable in the contructor of my base Controller (that all my Controllers inherit from).
This was too early. Not too early for the Application_Start() event, obviously. Just too early to be able to access it I assume.
So how early can I access ApplicationState?
I found I could access it without problem on the Initialize method of my BaseController:protected override void Initialize(System.Web.Routing.RequestContext requestContext) { base.Initialize(requestContext); //only here is the application state finally ready to be set SiteID = (int)requestContext.HttpContext.Application["SiteID"]; }
Problem is I really want to be able to access it during construction of my BaseController though since I will be implementing DI shortly. So in the end I used AppSettings in the config instead which can be accessed in the constructor. Still, this will still be useful I'm sure.
hfhjgfh
ReplyDelete<>
ReplyDeletehttps://www.olaladirectory.com.au/posts/dumpscafe-ncse-level-1-practice-test-questions-answers
ReplyDeletehttps://www.olaladirectory.com.au/posts/dumpscafe-mb-310-microsoft-dynamics-365-finance
https://www.olaladirectory.com.au/posts/dumpscafe-cka-certified-kubernetes-administrator-cka-program
Excellent read, Positive site, where did u come up with the information on this posting? I have read a few of the articles on your website now, and I really like your style. Thanks a million and please keep up the effective work,If anyone interested similar one's have a look here thanks.
ReplyDeleteshih tzu puppies for sale near me
buy puppy online
fuhrerschein-kaufen-schweiz