title: web api routing with action and id
body: <p>I am new in using web api and I am trying to call a specific method in my controller.</p>
  
  <p>I have </p>
  
  <p>global.asax</p>
  
  <pre><code>protected void Application_Start()
  {
      GlobalConfiguration.Configure(WebApiConfig.Register);
  }
  </code></pre>
  
  <p>the WebApiConfig class with these routings</p>
  
  <pre><code> // Web API routes
   config.MapHttpAttributeRoutes();
  
  
   config.Routes.MapHttpRoute(
        name: "ActionApi",
        routeTemplate: "api/{controller}/{action}/{id}",
        defaults: new
         {
            id = RouteParameter.Optional
         }
    );
  
  
  
   config.Routes.MapHttpRoute(
      name: "DefaultApi",
      routeTemplate: "api/{controller}/{id}",
      defaults: new
      {
         action="DefaultAction",
         id = RouteParameter.Optional
      }
   );  
  </code></pre>
  
  <p>and my controller</p>
  
  <pre><code>[HttpGet]
  public HttpResponseMessage GetPatSummary(string PatId)
  {
     PatientSummary Pat = new PatientSummary();
  
     HttpResponseMessage Response = new HttpResponseMessage();
     string yourJson = Pat.GetPatient(PatId);
     Response = this.Request.CreateResponse(HttpStatusCode.OK, yourJson);
     return Response;
  }
  
  [ActionName("DefaultAction")] //Map Action and you can name your method with any text
  public IHttpActionResult GetPatient(int id)
  {
      Object Obj = new object();
  
      if (Obj!=null)
      {
         return NotFound();
      }
      return Ok(Obj);
  }
  </code></pre>
  
  <p>the URL I am using is</p>
  
  <p><a href="http://localhost/mdmwapi/api/MdmwPatientController/GetPatSummary/sgdgdgddhdhd1334254" rel="nofollow">http://localhost/mdmwapi/api/MdmwPatientController/GetPatSummary/sgdgdgddhdhd1334254</a></p>
  
  <p>but I get this error
  A path segment cannot contain two consecutive parameters. They must be separated by a '/' or by a literal string.</p>
  
  <p>I am getting nut :-)</p>