nour
nour

Reputation: 29

Load file once into an ASP.NET application

I'm working on a web based app which in the core is an expert system, and I need to load the rules 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

Upvotes: 2

Views: 446

Answers (3)

rick schott
rick schott

Reputation: 20617

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.

Upvotes: 1

Adam Tuliper
Adam Tuliper

Reputation: 30152

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.

Upvotes: 1

SLaks
SLaks

Reputation: 887285

You're looking for the Application_Start event in Global.asax.cs.

Upvotes: 7

Related Questions