views:

336

answers:

4

I've got a lot of pages in my site, I'm trying to think of a nice way to separate these into areas that are a little more isolated than just simple directories under my base web project. Is there a way to put my web forms into a separate class library? If so, how is it done?

Thanks in advance.

+2  A: 

At first thought, I don't think this is possible, due to the way ASPX is non-precompiled..

However, you can create classes that inherit from Page and place them into a DLL to re-use code-behind functionality. This can of course include control instantiate logic if required, but there is no designer to work with (if you need it).

Rob Cooper
+1. ASPX being non-precompiled is my biggest issue with ASP.NET in general.
Randolpho
+1  A: 
Rob
+2  A: 

My question is, why do you want to do this?

If it's purely organisational then your "simple folders" should really be enough, so maybe you need to re-think your project structure.

If it is for compilation purposes, like it takes ages to recompile the site every time you change something, maybe you could split the site into multiple site project that each run as a subdomain of your main site.

These will then be recompiled separately.

If it's an organisational thing but related to management, in that you have loads of code and it's difficult to get around then maybe you should assess the way you are building the site. Would an N-Tier aproach or ASP.NET MVC provide better separation of your code?

What do you think?...

Greg B
Our application is split into sub modules. The business logic is bound into a library per module so we wish to have the same for the view layer that is associated with it. We're using ASP.NET MVC and Areas. Thoguht it would be cleaner to have a full seperation of modules. Thanks for your thoughts.
Odd
+1  A: 

You could also implement a VirtualPathProvider. I've seen this done to serve files from a single zip, they could also pull from a DLL.

Jon Galloway