I'm working on a web based app which in the core is an expert system, and I need to load the rul开发者_C百科es file to the app only once .. so I need an equivalent to public static void main() {}
in ASP.NET site to load the file in it .. what is this equivalent and is it exist .. any suggestions are highly welcome
You're looking for the Application_Start
event in Global.asax.cs.
This is done in (as @SLaks said) Application_Start. However - be very careful of doing any long operation here as you can run into problems. If this is a long operation, consider starting another thread or pre-processing this information into a table you can quickly load.
Auto-Start in ASP.NET 4 was built for this:
The new "auto start" feature of ASP.NET 4 and IIS 7.5 provides a well-defined approach that allows you to perform expensive application startup and pre-cache logic that can run before any end-users hit your application. This enables you to have your application "warmed up" and ready from the very beginning, and deliver a consistent high performance experience.
精彩评论