title: .NET MVC: How to implement different page appearance per user?
body: <p>I am running out of ideas here. Maybe you can advice me what pattern or method(s) to use.</p>
  
  <p>User should be able to log in and change the <strong>appearance only</strong> for his/her profile.
  The difference (AFAIK) with personalization is that personalized layout are seen only for the editor (him-/herself).
  The difference between skinning, I guess, is that Skins are predefined but users should be able to change the settings themselves.</p>
  
  <p>I need to be able to display the customized layout to everyone who visit author`s page.</p>
  
  <p>The good solution would be to keep the layout info in a DB table. Also it should be cached I guess to take load off the DB and used in CSS.</p>
  
  <p>Thanks</p>
  
  <p><strong>Edit:</strong></p>
  
  <p>OK I have done some research now. Came up with this kind of idea.</p>
  
  <p>In a View get a userId (Guid type) from a DB and set it to the ViewData:
  ViewData["userId"] = profile.userId;</p>
  
  <p>That View uses the following MasterPage called 'Profile.Master' and links to the dynamic CSS file:</p>
  
  <pre><code>    &lt;link href="&lt;%= Url.Action("Style", "Profile", 
          ViewData["userId"]) %&gt;" rel="stylesheet" type="text/css" /&gt;
  &lt;/head&gt;
  </code></pre>
  
  <p>In the ProfileController get the CSS data from DB and return it to the dynamic CSS View:</p>
  
  <pre><code>public ActionResult Style(Guid userId)
  {
      var styles = (from s in Db.UserStyleSet.OfType&lt;UserStyle&gt;()
                    where s.aspnet_Users.UserId == userId
                    select s);
  
      return View("Style", styles);
  }
  </code></pre>
  
  <p>The problem is that the UserId is never passed to the dynamic CSS link:</p>
  
  <p>The parameters dictionary contains a null entry for parameter 'userId' of non-nullable type 'System.Guid' for method 'System.Web.Mvc.ActionResult Style(System.Guid)' in 'Project.Controllers.ProfileController'.</p>
  
  <p>Any advice is welcome, thank you.</p>