场景:目前,我们在asp.net中有一个网站工具MVC
(www.tool.com/login)
。现在,客户端正在考虑为多个客户定制登录页面,他们将拥有自己的域(但只有一个服务器可供所有用户使用)。
例如:
www.client1.com/login
,
www.client2.com/login
,
www.client3.com/login
如果这是一个愚蠢的问题,请对我大喊。但是请帮忙,让我对如何实现它有所了解。我应该为每个客户端创建不同的登录html吗?
与我的评论有关-
ClientInfo
在DB中创建一个表:
假设您要传递模型->LoginModel
到您的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; }
}
在控制器中,加载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
}
};
}
然后在您的登录视图(LoginPage.cshtml)中:
@model LoginModel
<div style="background-color: @Model.BackGroundColor">
<h1>@Model.Title</h1>
</div>
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句