Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.Net - App_Data & App_Code folders?

What is the point of having App_code & App_data folders?

Why doesn't my objectDataSource detect classes unless files are in App_Code?

Please provide as much detail as you can, I'm new to ASP.Net

like image 311
aryaxt Avatar asked Sep 20 '11 05:09

aryaxt


People also ask

What is App_Data MVC?

App_Data. The App_Data folder of MVC application is used to contain the application related data files like . mdf files, LocalDB, and XML files, etc. The most important point that you need to remember is that IIS is never going to serve files from this App_Data folder.

Where is the App_Data folder?

You can view the AppData folder manually by going into your Users folder, which is there in the C drive. In my case, the path is C:\Users\ADMIN . Now you should be able to see the AppData folder in your User folder. You can also access the AppData folder directly using the AppData system variable.

Which are the ASP.NET folder?

In a dynamically compiled application, ASP.NET compiles the code in the App_Code folder on the initial request to your application. Items in this folder are then recompiled when any changes are detected. Arbitrary file types can be placed in the App_Code folder to create strongly typed objects.


2 Answers

These folders have special purpose. From this article - ASP.NET Web project folder structure.

App_Code


App_Code contains source code for shared classes and business objects (for example, ..cs, and .vb files) that you want to compile as part of your application. In a dynamically compiled Web site project, ASP.NET compiles the code in the App_Code folder on the initial request to your application. Items in this folder are then recompiled when any changes are detected.

Note : You can add any type of class file to the App_Code folder in order to create strongly typed objects that represent those classes. For example, if you put Web service files (.wsdl and .xsd files) in the App_Code folder, ASP.NET creates strongly typed proxies for those classes.

Code in the App_Code folder is referenced automatically in your application. The App_Code folder can contain sub-directories of files, which can include class files that in different programming languages.

App_Data


Contains application data files including .mdf database files, XML files, and other data store files. The App_Data folder is used by ASP.NET to store an application's local database, such as the database for maintaining membership and role information.

like image 96
KV Prajapati Avatar answered Oct 02 '22 16:10

KV Prajapati


To sum it up :

  • IIS will NEVER serve any file located in those folders (the same way it will not ever serve the Web.config file)
  • files in the App_Code folder will automatically be recompiled when a change occurs in the code.
like image 45
tsimbalar Avatar answered Oct 02 '22 15:10

tsimbalar