views:

1083

answers:

2

Hi, 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

A: 

The App_Code folder is mainly used with Website projects whereas with Web Application Projects you would typically reference the library class. App_Code is supposed to work with the WAP model but I find that it often doesn't play nice.

You can read more about it here (check the reference links): http://www.codersbarn.com/post/2008/06/01/ASPNET-Web-Site-versus-Web-Application-Project.aspx

IrishChieftain
+1  A: 

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.

AnthonyWJones
You need to create a reference to dll because VS doesn't know what you will name dll containing this class or...?
rubysons
May I ask another question - if I create (in code behind) another public class (besides the one from which page will derive) and if I set TypeName attribute of ObjectDataSource to this class, ODS for some reason won't find it
rubysons
Perhaps you should include a simple example of what you mean in your question.
AnthonyWJones