title: Encoding parameters for a URL
body: <p>I have a Silverlight application that is building a URL. This URL is a call to a REST-based service. This service expects a single parameter that represents a location. The location is in the form of "city, state". To build this URL, I'm calling the following code:</p>
  
  <pre><code>string url = "http://www.example.com/myService.svc/";
  url += HttpUtility.UrlEncode(locationTextBox.Text);
  </code></pre>
  
  <p>If a user enters "chicago, il" into locationTextBox, the result looks like this:</p>
  
  <pre class="lang-none prettyprint-override"><code>http://www.example.com/myService.svc/chicago%2c+il
  </code></pre>
  
  <p>In reality though, I was kind of expecting the URL to look like;</p>
  
  <pre class="lang-none prettyprint-override"><code>http://www.example.com/myService.svc/chicago,%20il
  </code></pre>
  
  <p>When testing my service via the browser URL, the one I am expecting works. However, the URL that is being generated is not working. What am I doing wrong?</p>