title: Creating a WebService inside my MVC project
body: <p><em>I know there's another thread about WebapiConfig.cs and RouteConfig.cs, but I can assure this is a different question.</em></p>
  
  <p>My MVC project was quite developed by the time I found out I would have to create a webservice (in the same domain) where I would grant access to one of my models (both in JSON and XML).</p>
  
  <p>In order to do so, I right clicked over my Controllers and selected "add Web API 2 Controller with actions, using Entity Framework" and selected also my model class and db context.</p>
  
  <p>The template was quite complete and I thought I was ready to go for the following test:</p>
  
  <pre><code>namespace MVC4GMAPS.Controllers
  {
      public class RestController : ApiController
      {
          private LocationDBContext db = new LocationDBContext();
  
          // GET api/Rest
          public IQueryable&lt;Location&gt; GetLocations()
          {
              return db.Locations;
          }
  etc...
  </code></pre>
  
  <p>Unfortunately, when I tried to access to <code>https://localhost:44300/api/Rest</code> I've got a 404. However, <code>localhost:44300/Home/Index</code> keeps working great.</p>
  
  <p>I believe the problem relies on my RouteConfig.cs, because it is expecting an {action} and my RestController doesn't have any actions:</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 }
              );
  etc...
  </code></pre>
  
  <p>What can I do? Can I create simultaneously a WebapiConfig.cs file? I believe not. I hope you can help me!</p>