Justin Ivins
Justin Ivins

Reputation: 13

Dynamically Load Master Page from Database for MVC App

This is the scenario. I want to be able to private label a website depending on the customer (stored as the subdomain). Now as customers sign up, we will design/store the private labeling in the database. I was hoping to store the private labeling as a master page file for each customer and load it on the fly from the database.

From what I have been searching, it doesn't seem possible. I see that I can set the ViewPage.MasterPageFile property, but that is string path to the master file on the file system.

The only way I thought of doing this would be to on the edit of the private labeling, save the entry directly to a .master file out on the file system, but that seems hacky.

Thanks for any insight before hand.

Upvotes: 1

Views: 718

Answers (2)

Tim Hobbs
Tim Hobbs

Reputation: 2017

Perhaps you could use an HTTP handler? You could pass a query param for the private labelling to output the master page HTML. Then you just set the ViewPage.MasterPageFile property to the handler + query param

Upvotes: 0

Alfero Chingono
Alfero Chingono

Reputation: 2663

Take a look at the VirtualPathProvider sample code here: http://support.microsoft.com/kb/910441

Upvotes: 1

Related Questions