title: MVC3 Razor - Is there a way to change the Layout depending on browser request?
body: <p>I followed this tutorial with success: <a href="http://www.hanselman.com/blog/MixMobileWebSitesWithASPNETMVCAndTheMobileBrowserDefinitionFile.aspx" rel="nofollow noreferrer">http://www.hanselman.com/blog/MixMobileWebSitesWithASPNETMVCAndTheMobileBrowserDefinitionFile.aspx</a></p>
  
  <p>All view are rendered with success when I access the page with mobile device. But, they are rendered with wrong layout (AKA masterpage).</p>
  
  <p>I have the following structure:
  /Views/Shared/Mobile/_Layout.cshtml
  /Views/Shared/_Layout.cshtml</p>
  
  <p>The problem is, I have to put the following statement in EVERY view:</p>
  
  <pre><code>Layout = "~/Views/Shared/Mobile/_Layout.cshtml";
  </code></pre>
  
  <p>Is there a place where I can place my logic to render one layout on another one?</p>
  
  <p>if (normalAccess) render normal _Layout.cshtml
  else (mobileAccess) render /Mobile/_Layout.cshtml</p>
  
  <p>I couldn't find where.</p>
  
  <p>Thanks for any help.</p>