Asp – Automatic reference of class files inside App_Code vs reference of class files outside App_Code

asp.netassembliescompilationnet

all questions refer to Web site projects.

1) Why are file classes inside App_Code folder automatically referenced by the rest of application, while file classes created outside App_Code aren’t?

2) I don’t know much about compilation, but why do we need to explicitly reference class files created outside App_Code? Because those files will be compiled into dlls created and named by programmer and as such VS doesn’t know what the names of these dlls and so can’t automatically reference these dlls?

3) Files outside App_Code by default don’t get automatically compiled? But why not?

thanx

Best Answer

Sounds to me like you are expecting Web Application behaviour from a Web Site "project".

In a Web site each ASPX/ASHX file (outside of the App_Code) is considered content. At any point you may wish to simply publish a few of the files to the web site. Hence compiling all them at once into a single assembly is not desirable.

With a Web Application you don't normally publish just a few files, you complete a phase of the application, compile it all together and then publish.

You seem to indicate you have "classes" declared outside of App_Code? Where would they be if not in their own dll project? If in a dll project then you need to create a project reference to in the Web Site properties.