title: ASP.NET automatically converts & to &amp;
body: <p>Minor issue, but it's driving me nuts nonetheless.</p>
  
  <p>I'm building a url for a <code>&lt;script&gt;</code> tag include to be rendered on an ASP.NET page, something like this:</p>
  
  <pre><code>&lt;script src='&lt;%= string.Format("http://example.com/page.aspx?a={0}&amp;b={1}&amp;c={2:0.00}", A, B, C)%&gt;' type='text/javascript'&gt;&lt;/script&gt;
  </code></pre>
  
  <p>Problem is when this is rendered, the <code>&amp;</code> characters are replaced with <code>&amp;amp;</code>:</p>
  
  <pre><code>&lt;script src='http://example.com/page.aspx?a=xxx&amp;amp;b=zzz&amp;amp;c=123.45' type='text/javascript'&gt;&lt;/script&gt;
  </code></pre>
  
  <p>I was expecting this, obviously:</p>
  
  <pre><code>&lt;script src='http://example.com/page.aspx?a=xxx&amp;b=zzz&amp;c=123.45' type='text/javascript'&gt;&lt;/script&gt;
  </code></pre>
  
  <p>However, if I render the url directly, outside the <code>&lt;script&gt;</code> tag, it looks ok! Just doing </p>
  
  <pre><code>&lt;%= string.Format("http://example.com/page.aspx?a={0}&amp;b={1}&amp;c={2:0.00}", A, B, C) %&gt;
  </code></pre>
  
  <p>Renders this:</p>
  
  <pre><code>http://example.com/page.aspx?a=xxx&amp;b=zzz&amp;c=123.45
  </code></pre>
  
  <p>What gives? And how do I stop this madness? My OCD can't take it!</p>