Saturday, March 31, 2012

Where do I keep common classes that every one of my pages should use?

I have several C# classes that I would like every page in my website to have access to. Is there some kind of "global" file I can put these into, or make them available some other way?

Thanks!

The standard way for small projects is to add it to the APP_CODE folder. If you don't have one, right click on the project and pick "Add ASP NET folder" and pick APP_CODE. That makes stuff generally consumable by your web site (double check your namespaces and stuff though!)

I put all global files in my App_Code Directory as do most asp.net developers from what I have seen. Then I add two subdirectories one BLL-Business Logic Layer and one DAL - Data Access Layer. This is a fairly standard way of doing it. This is known as the three tier model makes it easier when using claases that your grab accross many pages.

BC

0 comments:

Post a Comment