3

We're publishing two websites based out of one project.

The main site is a asp.net web forms web application, written in c#. The next one we are creating will derive from this. We want to be able to maintain both sites by editing the same code. So we don't have to edit simple changes in both projects.

The difference between the sites, are the css file(and maybe the master page). And some dependant code, like f.ex. login.

I figured I could do this using different build configurations.

First of all: Is this a good way to solve it?

If yes:

  1. How do I create a web.config file to load a different settings?
  2. How do I load different css file(and different master page).
  3. How do I create dependent code?

If no:

What would be?

Thanks for any help and tips contributed.

शेखर
  • 17,412
  • 13
  • 61
  • 117
Naoe
  • 1,209
  • 8
  • 12

3 Answers3

3

You would be better off creating two projects, but creating shared code as a dll that both projects can share.

Edmund Covington
  • 521
  • 6
  • 17
3

The css files you can change it on application_start event (assuming that you have two different host for the application).
You can change the master page at preInit event of page.

The better approach can be

  1. Create you business logic in a separate project.
  2. Try to create different Theme for different Client.
  3. Set the theme on Application_Start event.

You can also take advantage of DI (dependency injection) to call different method of different classes.

Community
  • 1
  • 1
शेखर
  • 17,412
  • 13
  • 61
  • 117
  • Thanks for your response. I've been reading up on your links, and will try this out in my project.(I would vote your answer up, but can't yet) – Naoe Jun 18 '13 at 07:39
1

I've worked on custom web CMS and therefore i have to create two websites doing some common functionalty. Here are my steps

  • Create a solution.
  • Add a class library type project
  • Add two different websites
  • Give reference of class library to both websites and you are good to go.
Ali Umair
  • 1,386
  • 1
  • 21
  • 42
  • Thanks for your response. The only problem with my project is that we have around 50 pages, heavy with code. Which are almost identical on both web sites, and that are still under development. Still I will take this into consideration :). – Naoe Jun 18 '13 at 07:33
  • Are you using role based security in your application ? – Ali Umair Jun 18 '13 at 07:53
  • Yes, and the two different sites does have different logic applied here. – Naoe Jun 19 '13 at 07:37
  • then make 2 roles as your for your websites and load different masterpages for your users. 1 website 2 different masterpages and login mechanism. check these links [link1](http://forums.asp.net/t/1464861.aspx/1) and [link2](http://stackoverflow.com/questions/8632166/load-different-master-pages-for-different-users) and – Ali Umair Jun 19 '13 at 10:38