0

Scenario: Currently, we have a website tool in asp.net MVC (www.tool.com/login). Now, the client is looking into customizing the login page for several customers and they will have their own domain (but only one server for all).

for example:

www.client1.com/login,

www.client2.com/login,

www.client3.com/login

Yell at me if this is a stupid question. But please help and give me an idea on how to implement it. Should I create different login htmls for each client?

Pawan
  • 1,704
  • 1
  • 16
  • 37
JADE
  • 475
  • 4
  • 12
  • 24
  • Why don't you accept it as a parameter from `client` browser like giving an option to provide which client he is and based on that log him in!! – Guruprasad J Rao Aug 25 '15 at 05:20
  • You can use the domain for each client to figure out which client is accessing the login. Given that, you can construct your view model to be customized for each client and use that to render custom html. – KnightFox Aug 25 '15 at 05:32
  • Have one login page with dynamic fields like client name, logo , style etc. Save this info against each client in the DB. So for client1 you have logo path, title and url = 'client1.com', when the login page is loaded get the URL Request (HttpContext.Current.Request.Url.Host) --> http://stackoverflow.com/questions/593709/how-to-get-the-url-of-the-current-page-in-c-sharp, then get related info from the DB based on URL - URL should be unique – Dawood Awan Aug 25 '15 at 07:56

2 Answers2

1

Related to my comment -

Create a Table with ClientInfo in DB:

  1. Title
  2. BackgroundColor
  3. Language
  4. URL --> This has to be unique for this to work [client1, client2]. Don't save the full URL -- Just the Host

Let's say you are passing a Model --> LoginModel to your LoginPage.cshtml

public class LoginModel
{
    public string UserName { get; set; }
    public string Password { get; set; }

    public StyleDTO ClientStyles { get; set; }

}


public class StyleDTO
{
    public string Title { get; set; }
    public string LogoPath { get; set; }
    public string BackGroundColor { get; set; }
}

In your controller when you load View:

    public ActionResult Login()
    {
        var clientUrl = HttpContext.Current.Request.Url.Host;

        var cs = dbContext.ClientInfo.First(s => s.Url == clientUrl);

        var model = new LoginModel()
        {

            ClientStyles = new StyleDTO()
            {
                Title = cs.Title,
                LogoPath = cs.LogoPath,
                BackGroundColor = cs.BackGroundColor
            }
        };
    }

then in your login View (LoginPage.cshtml):

@model LoginModel

<div style="background-color: @Model.BackGroundColor">

<h1>@Model.Title</h1>


</div>
Dawood Awan
  • 7,051
  • 10
  • 56
  • 119
0

create a config file with variables for client1, client2, client3

Keep same login page html and based on HTTP_referer pick one of the config variable and render the page based on that.

atinder
  • 2,080
  • 13
  • 15