Asp.net mvc - static constructor
This answer is completely general and not only for ASP.NET MVC.
-
Static constructors will run at most once per application domain. It made sure it runs before any static or instance access for that class. So no, it won't be called for every request.
-
Yes, static data travels across the entire application domain. Each application domain will have different static data. Therefore, unless you are using a web garden or web farm script, it is used for all users. Note: if you declare your static fields as
ThreadStatic
, they will only be available to one thread, which probably doesn't make much sense in an ASP.NET application.
source to share
If I understand your question correctly:
- Yes, you have global.aspx that contain event handlers for what you are looking for.
- The Application Cache will give you what you are looking for. Application.Cache or something that I cannot print from memory ...
Cheers and Merry Christmas (if applicable)
source to share