Have multiple ASP.NET web projects share pages and controls

Joined
Jul 17, 2006
Messages
4
Reaction score
0
Hi,

I have an existing ASP.NET/C# web application which I would like to replicate for use on another project. The other project will need slight modifications to the existing site, e.g. some different site text, some different logic in code-behind, the odd extra page here and there etc., but 95% of the site will remain the same.

My question is, what is the best practice for sharing code/pages between these two sites? I am using Visual Studio 2005, and cannot see an easy way of sharing .aspx pages, .ascx web controls, etc. between different web projects.

Naturally I don't want to simply create a copy of every page for each site, as this leads to twice the maintenance cost of having all the shared pages in the same place.

Many thanks in advance for any help/advice,

MrCeri
 
Joined
Jul 17, 2006
Messages
3
Reaction score
0
i think you can link the pages....

add existing item, then select the item and instead of clicking on Add, click on the arrow next to it and select Add as Link
 
Joined
Jul 17, 2006
Messages
4
Reaction score
0
Nope, I'm afraid there's no "add as link" option when adding existing aspx pages to a web project in Visual Studio 2005. Shame, that would be exactly the thing I would want! :)

Incidentally here are the possible solutions I've had suggested to me so far:

1) Copy all of the pages to the new website, and maintain both sites independently.
- obviously terrible from a maintenance point of view.

2) Move all of the code behind into classes in a shared assembly, and have the aspx pages inherit from these classes. It will still be necessary to have copies of all pages on each site, but the pages would now be super-thin, almost just html. All the logic from the code behind would now be in classes that can be shared between sites.
- still not ideal, as you still have to have a copy of each page maintained on each site, but at least there's less maintenance.

3) Use source control to maintain a copy of each web page in each of the sites.
- I haven't investigated this in too much detail, but I'm pretty sure it's possible. The danger here is from accidents happening where half the files in a directory are symbolically linked to other files, half are locally modified versions, and it all gets a bit confusing.

If anyone else can think of anything else, please let me know.

Cheers,

MrCeri
 
Joined
Jul 18, 2006
Messages
1
Reaction score
0
Source Control

The simplest solution is to store your code in Visual Source Safe (or a similar source control app) and to ALWAYS check in/out your files before you modify them. This will allow you to share files from project to project, and when a change is made you simply get the latest version in all of your projects (which you should be doing by habit every time you open a project, anyway).

I currently share twenty some controls like this, and it is absolutely simple to maintain.

Doug
 
Joined
Jul 17, 2006
Messages
4
Reaction score
0
crushmeguy said:
The simplest solution is to store your code in Visual Source Safe (or a similar source control app) and to ALWAYS check in/out your files before you modify them. This will allow you to share files from project to project, and when a change is made you simply get the latest version in all of your projects (which you should be doing by habit every time you open a project, anyway).

I currently share twenty some controls like this, and it is absolutely simple to maintain.

Doug

Yep, that was kind of what I was getting at with option 3 in my previous post.

Since originally posting I have had another suggestion, which is to re-factor all of my pages as re-usable controls, and move them into a shared class library. I guess it's an extension of option 2 I mentioned previously, but taking it a big step further (and greatly reducing maintenance costs).

This article certainly helps if anyone is interested in the details:

http://webproject.scottgu.com/CSharp/UserControls/UserControls.aspx

Cheers,
MrCeri
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,901
Latest member
Noble71S45

Latest Threads

Top