title: Url Path Encoding that actually works?
body: <p>According to RFC 3986 the valid characters for the path component are:</p>
  
  <pre><code>a-z A-Z 0-9 . - _ ~ ! $ &amp; ' ( ) * + , ; = : @
  </code></pre>
  
  <p>as well as percent-encoded characters and of course, the slash <code>/</code>.</p>
  
  <p>I can however not find a class that converts a string to well formatted path according to above rules.</p>
  
  <pre><code>string rawPath = "/A9_(+@*)/# ?/";
  string expectedPath = "/A9_(+@*)/%23%20%3f";
  </code></pre>
  
  <p>However, see code below:</p>
  
  <pre><code>string rawPath = "/A9_(+@*)/# ?/";
  Uri.EscapeDataString(rawPath); //Output=&gt;%2FA9_%28%2B%40%2A%29%2F%23%20%3F%2F
  Uri.EscapeUriString(rawPath); //Ouput=&gt;/A9_(+@*)/#%20?/
  HttpUtility.UrlPathEncode(rawPath); //Ouput=&gt;/A9_(+@*)/#%20?/
  </code></pre>
  
  <p>Nothing I tried leaves allowed characters unescaped and propery escapes all other characters.</p>
  
  <p>Hopefully somebody can save me from having to write my own utility!</p>