Been trying to work through this problem for a bit now. It is MVC4 C#
The jist: I require change the entire site layout based which domain contacted the server.
The details: My initial thoughts were that if someone entered on "bobsdiner.com" vs "susansCafe.com" that i would be able to put some logic in app_start to get the host name and then set the stylebundle to the correct stylesheet (additionally setting a _layout view would be fantastic as well). I have found out that IIS7 will not allow access to the request object in app_start any longer. I am a bit of a loss of where to go next where i can have a central code section instead of changing this for every controller (i have about 15 of them). In addition to all this i would like to be able to access the db with the host name as i do have a table that contains domain names and the stylesheet names.
any ideas are greatly appreciated!
I would forgo trying to change the style bundle and re-purpose the context switcher.
in the app start of the global asax, you can do something like this
DisplayModeProvider.Instance.Modes.Insert(0, new DefaultDisplayMode("Bobs")
{
ContextCondition = ctx => ctx.Request.Url.Host.Contains("bobsdiner")
});
So if you make your site look like susanscafe using the _layout.cshtml, and then create a bobs diner version by using _layout.Bobs.cshtml. you can specify the different look and feel there to get the effect you want.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.