title: Add random variable to link of CSS-file in ASP.NET .master file without using code behind?
body: <p>I have a SharePoint 2013 Server in a test environment at my customer. It is filtered through a cache instance called <a href="http://www.citrix.com/products/netscaler-application-delivery-controller/overview.html" rel="nofollow noreferrer">Net Scaler</a>, which does a good job delivering the same file to different clients. The problem is that it doesn't check if the file is new - it just pushes out what it got.</p>
  
  <p>Adding a css-variable such as <code>styles.css?ver=1000</code> solves the problem, and Net Scaler considers this as a new file. However, I'm having trouble making this unique on each page request.</p>
  
  <p>Since this is SharePoint 2013, I'm not allowed to edit code behind and is limited to the .master file. I've tried different markups, but nothing that works the way I expect it.</p>
  
  <p>This is my attempt so far, but it doesn't work as expected.</p>
  
  <pre><code>&lt;SharePoint:CssRegistration 
  name="/_catalogs/masterpage/Customer/Style/ResponsiveMaster.css?ver=
  &lt;%= DateTime.Now.ToString() %&gt;" runat="server" after="SharepointCssFile" /&gt;
  
  &lt;!-- or --&gt;
  
  &lt;link rel="stylesheet" type="text/css"
  href="/_catalogs/masterpage/Customer/Style/ResponsiveMaster.css?ver=
  &lt;%= DateTime.Now.ToString() %&gt;"  /&gt;
  </code></pre>
  
  <p>I even tried loading the css-file using inline JavaScript from this post <a href="https://stackoverflow.com/questions/574944/how-to-load-up-css-files-using-javascript">How to load up CSS files using Javascript?</a>:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
      //&lt;![CDATA[ 
          var $ = document; // shortcut
          var timestamp = Date.now();
          var cssId = '/_catalogs/masterpage/Customer/Style/ResponsiveMaster.css?ver=' + timestamp;  
          // you could encode the css path itself to generate id..
          if (!$.getElementById(cssId))
          {
              var head  = $.getElementsByTagName('head')[0];
              var link  = $.createElement('link');
              link.id   = cssId;
              link.rel  = 'stylesheet';
              link.type = 'text/css';
              link.href = '/_catalogs/masterpage/Customer/Style/ResponsiveMaster.css?ver=' + timestamp;
              link.media = 'all';
              head.appendChild(link);
          }
      //]]&gt;
  &lt;/script&gt;
  </code></pre>
  
  <p>But no luck there either. </p>