title: How can I encode characters in a URL for an ASP.NET WebAPI confirm email?
body: <p>I have an ASP.NET WebAPI application than needs to create a link for a confirmation email.  Here's the code for it:</p>
  
  <pre><code> callbackUrl1 = "http://localhost:2757/index.html" +
                  "?load=email" +
                  "&amp;userId=" + user.Id +
                  "&amp;code=" + code;
   await UserManager.SendEmailAsync(
      user.Id, 
      "Confirm your account", 
      "Please click this link: &lt;a href=\"" + callbackUrl1 + "\"&gt;link&lt;/a&gt;");
  </code></pre>
  
  <p>My code is almost working but it seems like I need to encode the data that goes into the query string. </p>
  
  <p>With MVC this was done like this:</p>
  
  <pre><code> var callbackUrl = Url.Action("ConfirmEmail", 
       "Account", 
       new { userId = user.Id, code = code }, 
       protocol: Request.Url.Scheme);
  </code></pre>
  
  <p>However I am not using MVC and when I tried adding it I got a number of unrelated problems. </p>
  
  <p>Can someone tell me how I can encode (if that's the right word) the data that goes up to make the link?</p>