Can we use App_Code folder in a ASP.NET Web application project?

 Posted by Ddd on 2/18/2011 | Category: ASP.NET Interview questions | Views: 10259 | Points: 40
Answer:

No, App_Code folder cannot be used in ASP.NET Web application project.
It is available in ASP.NET Web Site only.
You can check it, ASP.NET Web Application project: Solition Explorer:-->
Right click root->ASP.NET Folder-->App_Code will not be there.


Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Posted by: Letapz on: 4/24/2011 | Points: 10
Hi, you can't/shouldn't add the App_Code folder to a Web Application because this folder is designed for runtime compilation by asp.net and the Web Application project is designed for you to precompile your website into a dll which you can find in the Bin folder and deploy to your site. If you do add this manually, you may end up getting name clashes as the class will be precompiled to the dll and then asp.net will again try to recompile at runtime.

So, for Web App Projects, you should instead Add a folder called something like 'CodeFolder' and then add you class in there. Then right click properties on that class file and set its build config to compile rather than content.

I am working on my own web project for www.athenatennis.com.sg and am going thru a similar learning curve with that.

Login to post response