title: How to add Web API controller to an existing ASP.NET Core MVC?
body: <p>I created a project using the default ASP.NET Core MVC template. I would like to also create a RESTful API under <code>/api/{Controller}</code>. I added a new Web API controller (standard Web API controller class template) but I can't call it. I get an error saying that the page cannot be found. I tried adding a route in <em>Startup.cs</em> but it doesn't do anything:</p>
  
  <pre><code>app.UseMvc(routes =&gt;
  {
      routes.MapRoute(name: "default", template: "{controller=Home}/{action=Index}/{id?}");
      routes.MapRoute(name: "api", template: "api/{controller=Admin}");
  });
  </code></pre>
  
  <p>EDIT:</p>
  
  <p>Like I said, it's all default templates. Here's the Web API Controller that I added:</p>
  
  <pre><code>[Route("api/[controller]")]
  public class AdminController : Controller
  {                
      // GET api/values/5
      [HttpGet("{id}")]
      public string Get(int id)
      {
          return "value";
      }
  
      // POST api/values
      [HttpPost]
      public void Post([FromBody]string value)
      {
      }
  
      // PUT api/values/5
      [HttpPut("{id}")]
      public void Put(int id, [FromBody]string value)
      {
      }
  
      // DELETE api/values/5
      [HttpDelete("{id}")]
      public void Delete(int id)
      {
      }
  }
  </code></pre>