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

StackOverflow https://stackoverflow.com/questions/21085094

  •  27-09-2022
  •  | 
  •  

Pregunta

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

¿Fue útil?

Solución

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.

Otros consejos

There's a difference between ASP.NET WebSite and ASP.NET Web Application. It appears that you created a WebSite in which code files are stored the App_Code folder. If you create a web application you can place the code wherever you want an they will be compiled to assemblies that will be copied to the bin folder. This way you don't need to deploy your source code on the web server.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top