私は例を探していくつか見つけましたが、それらは全体的に大きなプロジェクトです。MVCマルチテナントアプリケーションの構築を開始する方法のサンプルを探しています。最初の部分はURLを解読することだと思います。
ASP.Netでは、これが私が行った方法です。DNNコードを見てこれを取得しました。MVCで同じことをどのように行いますか?
Global.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);
}
次に、ベースページでコンテキストから値を取得します。