title: Ampersands in URLRewriter Query Strings
body: <p>I have a query string parameter value that contains an ampersand. For example, a valid value for the parameter may be:</p>
  
  <pre><code>a &amp; b
  </code></pre>
  
  <p>When I generate the URL that contains the parameter, I'm using System.Web.HTTPUtility.UrlEncode() to make each element URL-friendly. It's (correctly) giving me a URL like:</p>
  
  <p><a href="http://example.com/foo?bar=a+%26b" rel="nofollow noreferrer">http://example.com/foo?bar=a+%26b</a></p>
  
  <p>The problem is that ASP.NET's Request object is interpreting the (encoded) ampersand as a Query String parameter delimiter, and is thus splitting my value into 2 parts (the first has "bar" as the parameter name; the second has a null name).</p>
  
  <p>It appears that ASP.NET is URL-decoding the URL first and then using that when parsing the query string.</p>
  
  <p>What's the best way to work around this?</p>
  
  <hr>
  
  <p><strong>UPDATE</strong>: The problem hinges on <a href="http://urlrewriter.net/" rel="nofollow noreferrer">URLRewriter</a> (a third-party plugin) and not ASP.NET itself. I've changed the title to reflect this, but I'll leave the rest of the question text as-is until I find out more about the problem.</p>