title: ASP.Net application runs slow at first time
body: <p>I have a web application written in ASP.Net 3.0 using C#, the production machine is a windows server 2003 with IIS 6.0 and sql server 2005.</p>
  
  <p><strong>Application Structure</strong></p>
  
  <p>The following shows the structure of my ASP.net web application: </p>
  
  <p>root application in IIS (//localhost/es) includes the common pages, for instance: master pages, theme, user control, images folder. 
  number of sub-projects under the root application (//localhost/es/sub-project).
  delete web.config in sub-projects
  assemble files of sub-projects is under bin folder of root application (sub-project properties >> compile >> build output path: ..\bin\ 
  my application is a 3–tier web application(Biasness layer ,Data layer and Presentation layer. Also, every aspx page has its code behind cs file)</p>
  
  <p><strong>IIS Settings</strong></p>
  
  <p>Application pool 
  Recycling Worker Process after "1740 in minutes" 
  Idle timeout worker processes after being idle "20 in minutes" 
  Ping worker process every "30 seconds"<br>
  Startup time limit for worker processer "90 Seconds" 
  Shoutdown time limit for worker processer "90 Seconds"</p>
  
  <p>Application Configuration<br>
  Cache limited ASP files in memory "500" </p>
  
  <p>Cache limited ASP files on disk "2000"</p>
  
  <p><strong>Deploying Application:</strong></p>
  
  <p>I publish the web application with all its files to production server. </p>
  
  <p>The Problem :</p>
  
  <p>The application runs pretty slow at the first time, it takes upwards 10 seconds to load, however every at the next time a page is requested it's be faster. I believe that the first time a page is requested, it compiles and it usually takes more time than the other requesting,
  because the page is in the Cache Memory. <strong>The question here is why it's take along time when compiling the page at first time?</strong> </p>
  
  <p><strong>Attempts to solve the Issue :</strong> </p>
  
  <p>I tried  to do the following :  </p>
  
  <ul>
  <li>Deploying a copy of the required files to production server.  </li>
  <li>Changed IIS settings, changed Idle timeout shut down of worker process  </li>
  <li>Turn off Tracing   </li>
  <li>Turn off Session State   </li>
  <li>Disable View State of a Page   </li>
  <li>Set debug=false in web.config   </li>
  <li>Creating a hello world sub-project under the root application ,  it takes 5 seconds . </li>
  <li>Creating separate hello word web application ,  as above it takes long time to load. </li>
  <li>Remove the code in the page_load event handler , but it didn't affect on the performance. </li>
  <li>Publish only the needed file of the root application (no code written in the code behind), and all file in the source code of sub-project (code is in the code behind) , </li>
  </ul>
  
  <p>However, the application still starts of slow but then it gets faster.</p>
  
  <p>Please help to diagnose and solve this problem.</p>