One site, multiple ui clients

I have an Asp.net Mvc site where I want to provide separate access and UI for different clients like: http://company1.mysite.com
http://company2.mysite.com
http: //company3.mysite .com

Each client will have a different ui, but almost the same functionality (or with some features disabled).
I would like to separate graphics for each client like logo, css and images.

What would be the best way to implement this?

0


source to share


3 answers


There are several things you can do. The first level, as mentioned, is to use a different CSS file. You can dynamically inject a different path to your CSS file by creating a Helper method. So it will be used something like this:

<link href="<%=AppHelper.GetCSSPath("mysite.css")%>" rel="stylesheet" type="text/css" />

      

This gives you some level of customization. The other layer will actually have different view files for each sub-site. You can do this by creating a new ViewEngine:



public class SubSiteViewEngine: WebFormViewEngine
{

  private string GetSiteRoot() {
   // some logic to get the site root from the incoming URL
  }

  public SubSiteViewEngine()
  {

    MasterLocationFormats = new[] { 
            GetSiteRoote() + "/Views/{1}/{0}.master", 
            GetSiteRoote() + "/Views/Shared/{0}.master" ,
            GetSiteRoote() + "/Views/Shared/MasterViews/{0}.master" 
        };
    ViewLocationFormats = new[] { 
            GetSiteRoote() + "/Views/{1}/{0}.aspx", 
            GetSiteRoote() + "/Views/{1}/{0}.ascx", 
            GetSiteRoote() + "/Views/Shared/{0}.aspx", 
            GetSiteRoote() + "/Views/Shared/{0}.ascx",
            GetSiteRoote() + "/Views/Shared/Controls/{0}.ascx" 
        };
    PartialViewLocationFormats = ViewLocationFormats;
  }

}

      

Hope it helps.

PS I'll be doing this shortly for my own project, so I will have some actual working code soon.

+1


source


Another option is to organize this using IIS. You will need to check the performance impact, but you can monitor each application (or pool) separately.

Basically what you do is make a different site for each tenant on your system. Point it to the app folder for the actual app code. The content of the variable (css, file library, maybe use your imagination ;-)) should then be added using a virtual directory pointing to your folder.



By using this approach, you will not run the risk of data crossover between tenants due to unexpected errors, etc.

+1


source


You have to check the incoming url and serve different CSS files for each one. You can use background images if you want to change images between companies.

Other recommendations:

  • Keep separate folders for different companies (and use root for common stuff)
  • If you need to disable certain features, do not ask for the company name, but ask if this is allowed in the current "profile".

    If Company = A then
       UseFunctionX = true
    else
       UseFunctionX = false
    
    //later in the code
    If UseFunctionX then
        // do domenthing
    
          

    So adding more profiles is easier

0


source







All Articles