asp.net mvc - Dynamically Managing MVC Layouts -


i have small mvc web project want able achieve following:

  1. select base page layout , css/javascript based upon active domain
  2. optionally allow base/default setting overridden @ start of session.

to achieve have created layout object following properties:

public class pagelayout {    public string reference { get; set; }    public string domain { get; set; }    public string layoutpath { get; set; }    public string csspath { get; set; }    public string javascriptpath { get; set; } } 

my idea being @ start of session, url checked layout parameter. example:

http://www.{domain}.com/tech 

in instance, pagelayout object reference "tech" retrieved. if no parameter found page layout object domain property matching active domain retrieved.

i have several questions regarding right way implement this:

  1. where best place implement logic in mvc? session_start method in global.asax seems potential candidate
  2. i want persist retrieved pagelayout object across whole session. going add session state via kind of management class.
  3. how make pagelayout data available each page. thought creating custom controller , adding viewbag (from session), master view implement following:

    @{ layout = viewbag.pagelayout.layoutpath; } ...

are better/cleaner/more appropriate mechanisms available achieve need?

yes there cleaner ways do, using third party tool , hook application.

you can take @ site, latest have been introduced http://razorc.net/

also take @ http://www.codeproject.com/articles/32847/asp-net-mvc-dynamic-themes http://codeofrob.com/entries/dynamically-switching-between-master-pages-in-asp.net-mvc.html


Comments

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -