Separate topics - if the same host address has www. and a version without www.

I have a set of themes for my site to be used with different requests for different urls. So if url = www.xyz.com load another theme and not www.abc.com.

However, I tried using a theme called www.abc.com and theme abc.com and in my webform code I have an event preinit page

that says if url.contains(abc.com)

, then load abc.com theme if url.contains(www.abc.com)

, load www.abc theme. com (valid topic).

Starting from the beginning, which is the best way to have and call a theme depending on whether the www. or not, but the same master. So how can I have separate themes for abc.com and www.abc.com and then load the latter when the url is www.abc.com and the first one when the url is obviously abc.com?

0


source to share


1 answer


Not really sure if you are here, but if you are testing url in that order and using else, then it looks like the first case will always be true, so check the more specific case (www).

Also let's say you look at testing url.StartsWith and include the protocol variations you might expect as you never know if these lines might appear elsewhere in the url in a year or two, and your theme switch might stop working.



Then you can just swap master pages to change the theme, or if you are using the App_Theme app do some inclusion of this. Always found the aspnet theme to be a little clunky.

+1


source







All Articles