IN my asp.net MVC4 project I have few .cs files under the app_start folder that needs to be initialized or perform per-authorization tasks etc. When you access the website they take quite a lot of time to perform all these tasks on application start for first time. Is it possible to run all files under app_start folder automatically while deployment. So that when someone access the website for the first time it wont take that much time.
Take a look at auto-starting your application
Add this to your applicationHost.config
<sites>
<site name="MySite" id="1">
<application path="/"
serviceAutoStartEnabled="true"
serviceAutoStartProvider="PreWarmMyCache" />
</site>
</sites>
<serviceAutoStartProviders>
<add name="PreWarmMyCache" type="PreWarmCache, MyAssembly" />
</serviceAutoStartProviders>
and the following to preload your work
public class PreWarmCache : System.Web.Hosting.IProcessHostPreloadClient {
public void Preload(string[] parameters) {
// Perform initialization and cache loading logic here...
}
}