ASP.Net - App_Data & App_Code folders?

有些话、适合烂在心里 提交于 2019-12-17 16:32:03

问题


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


回答1:


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.




回答2:


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.



回答3:


They're mainly used with the Website template. Use the ASP.NET project template instead and avoid using these folders, especially if you are creating libraries or user controls.

http://www.codersbarn.com/post/2008/06/01/ASPNET-Web-Site-versus-Web-Application-Project.aspx



来源:https://stackoverflow.com/questions/7480437/asp-net-app-data-app-code-folders

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!