Search code examples
asp.net.class-fileapp-code

It is only able to refer the class files inside App_Code folder in a file in ASP .NET website application


Only the class files inside App_Code folder is able to refer in a file in ASP .NET website application. Why its so?


Solution

  • Only the class files inside App_Code folder is able to refer in a file in 
    ASP .NET website application. Why its so?
    

    The answer is very simple Website application working as designed.

    App_Code folder is a special ASP.NET RUNTIME folder.Any files in this folder are compiled by ASP.NET when your site is actually running on the server.

    This essentially allows you to drop random class/code files in this folder to be compiled on the server side. For this very reason if you drop something new into the App_Code folder of your running web site, it is like resetting it coz ASP.NET runtime now recognizes that there is a new class which needs to be kept in consideration during running the site. This magical folder brings with itself various connotations when it comes to different project typescourtesy

    ASP.NET decide at runtime which compiler to invoke for the App_Code folder based on the files it contains. If the App_Code folder contains .vb files, ASP.NET uses the VB compiler. if it contains .cs files, ASP.NET uses the C# compiler, and so on...

    You can refer the following resources too.