2

I have an MVC4 webapplication serving a website. Now I want to use that same webapplication for serving other websites (other URL's) as some sort of whitelabel engine. Essentially I want to use same controllers but customize on header, style and occasionally on content.

I don't want to create variants of the same webapplication. What's the best way to go about this? I was thinking about detecting the URL from each controller and acting upon that. But it feels like detecting the URL could be done higher in the call stack.

Of course, other solutions are welcome as well. I'm basically looking for the most pragmatic way to implement this.

2 Answers 2

2

If they will be on different domain names, just check the host header. Then in your table where you have all the whitelabel information (for instance, tbl_Site), just add a new column: Host.

Then in your controller, read the host header and use that to query your tb_Site and determine what site they are accessing and customize on that.

You will need to have all of the domain names point to the same (static) IP address.

Sign up to request clarification or add additional context in comments.

1 Comment

Thx for your answer. I indeed derived domain name from HTTP_HOST and matched that against my Labels-table. I expanded each model with a Label-object which is populated at start of each Controller. Now each View is aware of the Label it needs to adapt to.
1

We have a similar solution we implemented using multiple binds in the same iis site (iismanager -> right click a site -> edit bindings).

Inside the application we use a helper class and a database to parameterize the resources based on the request domain.

1 Comment

Thx for your answer. It is correct but I found the other one just a little more helpfull.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.