title: C# HttpWebRequest of type "application/x-www-form-urlencoded" - how to send '&' character in content body?
body: <p>I'm writing a small API-connected application in C#.</p>
  
  <p>I connect to a API which has a method that takes a long string, the contents of a calendar(ics) file.</p>
  
  <p>I'm doing it like this:</p>
  
  <pre><code>HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(URL);
  request.Method = "POST";
  request.AllowAutoRedirect = false;
  request.CookieContainer = my_cookie_container;
  request.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";
  request.ContentType = "application/x-www-form-urlencoded";
  
  string iCalStr = GetCalendarAsString();
  
  string strNew = "&amp;uploadfile=true&amp;file=" + iCalStr;
  
  using (StreamWriter stOut = new StreamWriter(request.GetRequestStream(), System.Text.Encoding.ASCII))
   {
       stOut.Write(strNew);
       stOut.Close();
   }
  </code></pre>
  
  <p>This seems to work great, until I add some specific HTML in my calendar.</p>
  
  <p>If I have a '&amp;nbsp' somewhere in my calendar (or similar) the server only gets all the data up to the '&amp;'-point, so I'm assuming the '&amp;' makes it look like anything after this point belongs to a new parameter?</p>
  
  <p>How can I fix this?</p>