How to handle a multi-site environment

45 Views Asked by At

If I have an application in WebPages, I would like to know how to enable multi-site capabilities? I understand the _SiteLayout.cshtml file or what not can handle the template for one site, but how about if I wanted to change that for a different site? The different site would be passed to the application by ServerVariable (domain name), so I'm assuming there would need to be some type of controller in place to handle this? But WebPages doesn't have controllers and I'm not learning MVC now. What would be my options at this point? Thank you.

1

There are 1 best solutions below

0
On BEST ANSWER

You could check the requested domain and then select the layout page, like this:

@{
    if (Request.Url.Host == "domain1.com")
    {
        Layout = "/Shared/_Layout1.cshtml";
    }
    else if (Request.Url.Host == "domain2.com")
    {
        Layout = "/Shared/_Layout2.cshtml";
    }
    else
    { 
        Layout = "/Shared/_Layout.cshtml";
    }
}