title: How should I load a CSS style based on user setting?
body: <p>In my ASP.NET MVC website people can choose between different css styles. In the future the name of these css styles will be stored in a database.</p>
  
  <p>I have the following method <em>(does not yet communicate with a database)</em>:</p>
  
  <pre><code>public FileResult CssStyle()
  {
      string style = "/Content/wide-site.css";
  
      if (!String.IsNullOrWhiteSpace(style))
      {
          return File(style, "text/css");
      }
  
      return File("/Content/site.css", "text/css");
  }
  </code></pre>
  
  <p>And in my _Layout.cshtml I use this line to load the stylesheet:</p>
  
  <pre><code>&lt;link href="@Url.Action("CssStyle", "Home")" rel="stylesheet" type="text/css" /&gt;
  </code></pre>
  
  <p>Suppose that this CssStyle() method does a request to the database and for every page load it executes a query. What's the best way to prevent these unnecessary requests? A session perhaps?</p>