views:

43

answers:

3

How ASP.NET compiles its assemblies generally confuses me. It seems that I cannot program against anything outside the *App_Code* folder. In the application I am working on I have several server side controls and a few user controls. The user controls are outside the *App_Code* folder and I cannot refer to them from the *App_Code* folder. It is a "Web Site" project.

How can I refer to the UserControls from the *App_Code* directory? Is this a compilation issue?

Thanks in advance.

A: 

The way that I have gotten around the app_code issue is by putting all of my classes into a separate project and include the dll from that project as a reference in the web project. That also allows me to reuse the classes in other applications. I believe this is a common practice for business logic and data access when building an application using an n-tier environment.

fizch
+1  A: 

Yes, it is a compilation issue, read a bit more about this same question at

http://www.velocityreviews.com/forums/t119801-accessing-web-user-control-from-class-in-appcode-folder.html

Whilst I'm sure suggesting you convert the web site to a web application is something you have considered doing and rejected, it may be the way forward if accessing your user controls is something you're looking to do frequently.

Justin Wignall
I am not opposed to converting to a Web Application but my boss might be. Thank you for your suggestion.
smaclell
A: 

Are you sure you're referencing the namespace which contains the user controls?

upsidedowncreature
They are actually in the same namespace. I wanted to make that consistent so that they are both in the "Controls" namespace.
smaclell