Since I am using VS 2008 Professional I decided to follow Imar's book examples but using a
Web Application Project.
In Chapter 5, p. 167, he speaks of adding the
App_Code folder from a set of options offered when one right clicks on the name of the site. In my case the name is actually the project name and App_Code is not offered as one of the options. Nonetheless, I like the idea of having classes grouped in a separate directory, so I manually added an App_Code folder and created the Calculator.cs file therein. FWIW, the special icon appears as described by Imar.
The project would not compile. I found a several things.
First, Web Application Projects do not offer the App_Code option, since, as described by Mikhail Arkhipov of Microsoft says at
here, "You don't need App_Code in Web Application since all code files are compiled during the build, as in client projects. You can place code files anywhere in [Web Application Project]. Well not anywhere, at least not with some fussing.
Second, the properties - Build Action of Calculator.cs had to be changed from "Content" to "Compile".
Finally, the namespace, which was automatically created within Calculator.cs when I added the new item Calculator.cs to the App_Code folder of "Site.App_Code" had to be changed to just "Site".
Everything worked after all that.
Seems like a lot to go through. I tried just adding Calculator.cs to the main Site directory directly and it worked immediately. I tried using a different folder name for the code and again the namespace was "Site.foldername".
Any thoughts?
Thomas