title: Routes in ASP.net Core API
body: <p>I read lot of topic about routes for API in Asp.net core but I cannot make it work.</p>
  
  <p>First, this is my controller :</p>
  
  <pre><code>Public class BXLogsController : Controller
  {
      //[HttpGet("api/[controller]/ID/{id}", Name = "GetL")]
      public IActionResult GetById(string id)
      {
          if (id.Trim() == "")
              return BadRequest();
          else
          {
              Logs l = AccessBase.AccBase.GetLog(id);
              return Json(l);
          }
      }
  
      //[HttpGet("api/[controller]/API/{apiname}", Name = "GetLAPI")]
      public IActionResult GetByAPI(string apiname)
      {
          if (apiname.Trim() == "")
              return BadRequest();
          else
          {
              List&lt;Logs&gt; lstLogs = AccessBase.AccBase.GetLogsApi(apiname);
              return Json(lstLogs);
          }
      }
  }
  </code></pre>
  
  <p>I tried to use the <code>HttpGetAttribute</code> with the path (refer to comment) but that doesn't work.</p>
  
  <p>So I want to use <code>MapRoute</code> approach but that doesn't work also.</p>
  
  <pre><code>app.UseMvc(routes =&gt;
  {
      routes.MapRoute(
          name: "LogsId",
          template: "api/[controller]/ID/{id}",
          defaults: new { controller = "BXLogs", action = "GetById" });
  
      routes.MapRoute(
          name: "LogsAPI",
          template: "api/[controller]/API/{apiname}",
          defaults: new { controller = "BXLogs", action = "GetByAPI" });
  });
  </code></pre>
  
  <p>I must have forgotten something but I see nothing.</p>
  
  <p>Anyone can help me ?</p>