title: Getting No HTTP resource was found that matches the request URI
body: <p>I'm having the following error when trying to hit my webapi code from another site.</p>
  
  <p>Here's the json message being returned.</p>
  
  <pre><code>    "Message":"No HTTP resource was found that matches the request URI 
  'http://localhost:47845/api/Test?samAccountName=aasdf&amp;success=True&amp;permissionName=bla'.","MessageDetail":
  "No action was found on the controller 'Test' that matches the request."
  </code></pre>
  
  <p>When I hit the site directly, 
  <a href="http://MyServer/ApiToHit/api/Values?samAccountName=someAccount&amp;success=True&amp;permissionName=MyPermission" rel="nofollow noreferrer">http://MyServer/ApiToHit/api/Values?samAccountName=someAccount&amp;success=True&amp;permissionName=MyPermission</a></p>
  
  <p>I get a nice success string.</p>
  
  <p>When I hit it with the following code, I get the error message above.</p>
  
  <pre><code>using (var client = new HttpClient(new HttpClientHandler { UseDefaultCredentials = true }))
              {
                  client.DefaultRequestHeaders.Accept.Clear();
                  client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
  
  
                  var values = HttpUtility.UrlDecode(string.Format(
                      CultureInfo.InvariantCulture, ConfigurationManager.AppSettings["PathToParameters"].ToString(),
                      "someAccount".ToUpper(CultureInfo.InvariantCulture),
                      true.ToString(),
                      "MyPermission".ToUpper(CultureInfo.InvariantCulture)));
  
                  lblResult.Text = string.Empty;
  
                  var newUrl = new Uri(ConfigurationManager.AppSettings["Url"].ToString() + values);
  
                  // HTTP GET
                  var response = await client.GetAsync(newUrl, HttpCompletionOption.ResponseHeadersRead).ConfigureAwait(false);
                  //var response = await client.GetAsync(values, HttpCompletionOption.ResponseHeadersRead).ConfigureAwait(false);
                  this.lblResult.Text = await response.Content.ReadAsStringAsync();
              }
  </code></pre>
  
  <p>Here's my api controller</p>
  
  <pre><code>public class TestController : ApiController
  {
      // GET: api/Test
      public string Get(string samAccountName, bool success, string permissionName)
      {
          var returnValue = "Success";
  
          return returnValue;
      }
  }
  </code></pre>
  
  <p>Here's my route</p>
  
  <pre><code>  public class RouteConfig
      {
          public static void RegisterRoutes(RouteCollection routes)
          {
              routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
  
              routes.MapRoute(
                  name: "Default",
                  url: "{controller}/{action}/{id}",
                  defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
              );
  
  
          }
      }
  
  public static void Register(HttpConfiguration config)
          {
              // Web API configuration and services
  
              // Web API routes
              config.MapHttpAttributeRoutes();
  
              config.Routes.MapHttpRoute(
                  name: "DefaultApi",
                  routeTemplate: "api/{controller}/{id}",
                  defaults: new { id = RouteParameter.Optional }
              );
          }
  </code></pre>