Search code examples
c#asp.netcompilationstartupaspnet-compiler

Precompilation and startup times on ASP.Net


I am developping a (relatively small) website in ASP.Net 2.0. I am also using nAnt to perform some easy tweaking on my project before delivering executables. In its current state, the website is "precompiled" using

aspnet_compiler.exe -nologo -v ${Appname} -u ${target}

I have noticed that after the IIS pool is restarted (after a idle shutdown or a recycle), the application takes up to 20 seconds before it is back online (and Application_start is reached).

I don't have the same issue when I am debugging directly within Visual Studio (it takes 2 seconds to start) so I am wondering if the aspnet_compiler is really such a good idea.

I couldn't find much on MSDN. How do you compile your websites for production?


Solution

  • Make sure that:

    1. You are using a Web Application project rather than a Web Site project, this will result in a precompiled binary for your code behind
    2. You have turned off debug code generation in the web.config file - I guess if this is different to when you used aspnet_compiler the code may be recompiled

    If you've tried those, you could maybe try running ngen over your assembly thus saving the JIT time?