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.
Best Answer
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: