tags:

views:

86

answers:

1

ok so I created this master page file and in its Page_PreInit added the code to change master page at run time after detecing a visitor's country:-

Now, while researching I came across this thread that says "Setting the master page in Page_PreInit event is against the design and spirit of MVC..what is this supposed to mean ???

If not this way, how else am I supposed to change master pages at run time???

+1  A: 

I can only guess what the author of the thread means by the 'Spirit' of MVC. MVC is a tool just like any other in your kit. There are better ways to use tools as well as ways to abuse tools.

I think the answer depends on what is in your master pages. More specifically, what is different between the various countries. If it is largely a matter of layout, logos, colors and other styling, then perhaps this is better handled in your css by injecting a different stylesheet based on the country.

If it is more to do with content and language, then you should probably step back and examine your routing strategy. A common approach is to include country codes in the url. eg: domain.com/UK/product/1 or domain.com/DE/product/1

Another thing to look at is MVC Areas. Although it is usually used for functionally different parts of a site, I have seen Areas used to partition sites along cultural/country boundaries with some success. This is usually better when there are large functional differences between the different country sites.

Daniel Dyson