我已经搜索了示例并找到了几个,但它们是整个大型项目。我正在寻找一些关于如何开始构建 MVC 多租户应用程序的示例。我认为,第一部分是破译网址。
在 ASP.Net 中,我就是这样做的。我通过查看 DNN 代码得到了这个。我将如何在 MVC 中做同样的事情?
全球.asax
private void Application_BeginRequest(Object source, EventArgs e)
{
HttpApplication application = (HttpApplication)source;
HttpContext context = application.Context;
string domainName = string.Empty;
// domaName now contains 'example' if application.Request was www.example.com
domainName = GetDomainName(application.Request);
// Using domain, get the info for example from the database
object myPortal = // get from database
// Save in context for use on other pages
context.Items.Add("PortalSettings", myPortal);
}
然后在我的基本页面中,我从上下文中获取值。