title: .Net Uri Encoding RFC 2396 vs RFC 3986
body: <p>First, some quick background... As part of an integration with a third party vendor, I have a C# .Net web application that receives a URL with a bunch of information in the query string. That URL is signed with an MD5 hash and a shared secret key. Basically, I pull in the query string, remove their hash, perform my own hash on the remaining query string, and make sure mine matches the one that was supplied.</p>
  
  <p>I'm retrieving the Uri in the following way...</p>
  
  <pre><code>Uri uriFromVendor = new Uri(Request.Url.ToString());
  string queryFromVendor = uriFromVendor.Query.Substring(1); //Substring to remove question mark
  </code></pre>
  
  <p>My issue is stemming from query strings that contain special characters like an umlaut (ü). The vendor is calculating their hash based on the RFC 2396 representation which is <code>%FC</code>. My C# .Net app is calculating it's hash based on the RFC 3986 representation which is <code>%C3%BC</code>. Needless to say, our hashes don't match, and I throw my errors.</p>
  
  <p>Strangely, the <a href="http://msdn.microsoft.com/en-us/library/system.uri.aspx" rel="noreferrer">documentation for the Uri class in .Net</a> says that it should follow RFC 2396 unless otherwise set to RFC 3986, but I don't have the entry in my <code>web.config</code> file that they say is required for this behavior.</p>
  
  <p>How can I force the Uri constructor to use the RFC 2396 convention?</p>
  
  <p>Failing that, is there an easy way to convert the RFC 3986 octet pairs to RFC 2396 octets?</p>