Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am wondering about performance of a web site/application when there is code in the code behind files rather than when the code is moved to separate files in the App_Code folder.

My understanding is that the code behind gets compiled and executed every time they are requested by the user. If this is not the case, please let me know. Also, it is my understanding that the code in the App_Code file gets compiled once.

With these understandings, it would seem that moving code the App_Code folder would speed up requests. I understand that there wont be any significant gains until you have lots of files and lots of requests very frequently. However, will this cause any performance value?

Also, by performance I am talking about speed. Specifically speed of client side load. And I know there are other factors that can increase speed on the users end, but I am specifically asking about the above situation.

share|improve this question
If it's an "web application" and not "web site" then you should see no difference, as web applications do not use dynamic compilation. – Matthew Apr 5 '14 at 15:57
@Matthew thanks for the response. Does that mean you will see a difference in a web site? – DFord Apr 5 '14 at 16:03

Your understanding is incorrect. Both the App_Code and aspx files are compiled just once and then cached. Individual files are only compiled when used (at least that's the most common case).

There is a performance hit when a page is first hit, as it has to be compiled, if this is a problem web sites may not be for you.

See Understanding ASP.NET Dynamic Compilation:

In order for your Web application to service requests, ASP.NET must first parse and compile the code of your Web application into one or more assemblies. When the code is compiled, it is translated into a language-independent and CPU-independent representation called Microsoft Intermediate Language (MSIL). At run time, MSIL runs in the context of the .NET Framework, which translates MSIL into CPU-specific instructions for the processor on the computer running the application.

ASP.NET dynamic compilation enables you to modify your source code without having to explicitly compile your code before you deploy your Web application. If you modify a source file, ASP.NET automatically recompiles the file and updates all linked resources. The IIS server does not have to be restarted for the changes to take effect unless the <processModel> section has been changed...

By default, ASP.NET Web pages and code files are compiled dynamically when users first request a resource, such as an ASP.NET page (.aspx file), from a Web site. After pages and code files have been compiled the first time, the compiled resources are cached, so that subsequent requests to the same page are extremely efficient...

share|improve this answer
So when i change something within <processModel> element, i NEED to do IISRESET, right? – psulek Oct 23 '15 at 9:57

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.