title: WebAPI route to root URL
body: <p>I have a WebAPI application that is used for some RESTful operations in the database. It works great, but I want to match a route with the root URL. For example, I want to go to the root of the site and see some useful information that are dynamically generated. </p>
  
  <p>Currently, I have it setup so that it follows the standard convention of <code>api/{controller}/{action}</code>, but how can I show this information when navigated to the root instead of something like <code>api/diagnostics/all</code>?</p>
  
  <p>Basically what I want is, when the user navigates to the root URL, I want to route that request to <code>TestController.Index()</code></p>
  
  <p>I have the following setup in the WebApiConfig.cs file:</p>
  
  <pre><code>public static void Register(HttpConfiguration config)
  {
      // Web API routes
      config.MapHttpAttributeRoutes();
  
      config.Routes.MapHttpRoute(
          name: "Index",
          routeTemplate: "",
          defaults: new { controller = "Test", action = "Index" }
      );
  
      config.Routes.MapHttpRoute(
          name: "DefaultApi",
          routeTemplate: "api/{controller}/{id}",
          defaults: new { id = RouteParameter.Optional, controller = "Test" }
      );
  }
  </code></pre>
  
  <p>And this is what my TestController.cs looks like:</p>
  
  <pre><code>[RoutePrefix("api")]
  public class TestController : ApiController
  {
  
      [Route("TestService"), HttpGet]
      public string Index()
      {
           return "Service is running normally...";
      }        
  }
  </code></pre>