Steve Costello
Steve Costello

Reputation: 380

Domain and/or subdomain sharing of folder(s) in Visual Studio and on IIS7 - How to?

I'm in the process of completely redesigning/redeveloping our corporate website, and am about to set up the skeleton in VS2010 and TFS, as well as get things prepped in our DEV and QA environments. Our company has some separate business units that either handle a certain business focus or are businesses we've taken over that are not or will not fall under our corporate name and main domain.

The overall idea behind the redesign is to unify the look and feel of all the sites, with a few exceptions for individuality such as logos and certain design elements like header backgrounds that will reflect the 'corporate' colors of those units. Otherwise, all other design resources (such as icons, etc.) as well as most JavaScript and BL (most likely via web services) will be shared. I'd like to set things up such that I do not need to push resources to multiple sites. One place for all sites to get their resources.

ALL of that said: How should this project be set up in Visual Studio, and by extension, IIS7? I need to account for not only our main corporate domain, but the other business units, which may either have their own domain, or just a sub-domain.

My first thought is to set up App_Themes, Scripts and a Web Services folder for the shared resources. Then each domain/sub-domain goes into its own folder in the same Project, and those domain/sub-domain folders are set up as Virtual Directories in IIS. Does this sound like the best way to go, or will that create problems, or ultimately not be the right solution?

Update:

So far, not so good. I've set up a solution with one project. That project has multiple folders, one for each site as well as a folder for scripts, images, and css. Each folder has been set up as a Virtual in IIS. I have a default.aspx page that uses a masterpage in the root of the project. That actually works fine. However, any script or css references do not. Which, logically, makes sense.

How do I get around this? Am I approaching this the wrong way?

Upvotes: 2

Views: 691

Answers (1)

Blaise
Blaise

Reputation: 22212

I am a little concerned about your plan:

Then each domain/sub-domain goes into its own folder in the same Project

The better choice should be each domain/sub-domain goes into its own folder as individual project.

I learned this from the book Microsoft.Press.Programming.Microsoft.ASP.NET.MVC.2nd.Edition.Oct.2011. Well the book itself is about MVC programming. But the downloadable source code is an excellent example of the overall architecture.

The book: from its publisher's site The source code: Companion Content

My site structure is basically a copy and modification of their work.

  • Folder Lib contains anything common to all websites. [In the downloaded code, it anything shared among example web applications in all chapters.] We put class library projects in it.

    1. DAL: domain models and their interfaces
    2. Utils" DateExtensions, EnumExtensions
  • Folder Package contains all external dll's such as EntityFramework, DataAnnotation... Use it if we need to publish those packages along instead of installing it on IIS.

  • Folder Sites contains all web applications (domain and subdomain).[In their code, it is all their sample applications placed under each chapter folder.]

Personally, I love this kind of architecture. If you want to use shared CSS files, a possible makeshift solution is to host the common CSS files in one website, and other sites will just reference it using a full url.

And the book author Dino Esposito has also published Microsoft® .NET: Architecting Applications for the Enterprise. He is truly expert in system design. So far I feel safe and comfortable to follow his examples. If anyone has better advice, please do not hesitate to let us know.

Upvotes: 1

Related Questions