title: How to Use MVC Controller and WebAPI Controller in same project
body: <p>I am trying to use an MVC Controller and a Web API controller in the same project, but I get 404 errors for the Web API. I started the project as an MVC project in VS 2015, but then added the Web API controller, and with the default code it is giving a 404 error.</p>
  
  <p>What could be the possible solution? I have tried some solutions on Stack Overflow, but they didn't work. One I tried is the accepted answer from this question: <a href="https://stackoverflow.com/questions/15556035/all-asp-net-web-api-controllers-return-404">All ASP.NET Web API controllers return 404</a></p>
  
  <p><strong>Global.asax:</strong></p>
  
  <pre><code>protected void Application_Start()
  {
      AreaRegistration.RegisterAllAreas();
      GlobalConfiguration.Configure(WebApiConfig.Register);//WEB API 1st
      FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
      RouteConfig.RegisterRoutes(RouteTable.Routes);
      BundleConfig.RegisterBundles(BundleTable.Bundles);
  }
  </code></pre>
  
  <p><strong>WebApiConfig:</strong> </p>
  
  <pre><code>public static class WebApiConfig
  {
      public static void Register(HttpConfiguration config)
      {
          config.MapHttpAttributeRoutes();
  
          config.Routes.MapHttpRoute(
              name: "DefaultApi",
              routeTemplate: "api/{controller}/{id}",
              defaults: new { id = RouteParameter.Optional }
          );
      }
  }
  </code></pre>
  
  <p><strong>RouteConfig</strong>:</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 }
          );
      }
  }
  </code></pre>
  
  <p><strong>Web API Controller:</strong></p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Net;
  using System.Net.Http;
  using System.Web.Http;
  using O365_APIs_Start_ASPNET_MVC.Models;
  using Microsoft.IdentityModel.Clients.ActiveDirectory;
  using O365_APIs_Start_ASPNET_MVC.Helpers;
  using System.Threading.Tasks;
  
  namespace O365_APIs_Start_ASPNET_MVC.Controllers
  {
      public class MAILAPIController : ApiController
      {
          private MailOperations _mailOperations = new MailOperations();
          //async Task&lt;BackOfficeResponse&lt;List&lt;Country&gt;&gt;&gt;
  
          // GET: api/MAILAPI
          public IEnumerable&lt;string&gt; Get()
          {
              return new string[] { "value1", "value2" };
          }
  
          // GET: api/MAILAPI/5
          public string Get(int id)
          {
              return "value";
          }
  
          // POST: api/MAILAPI
          public void Post([FromBody]string value)
          {
          }
  
          // PUT: api/MAILAPI/5
          public void Put(int id, [FromBody]string value)
          {
          }
  
          // DELETE: api/MAILAPI/5
          public void Delete(int id)
          {
          }
      }
  }
  </code></pre>
  
  <p>I'm also getting an error restoring NuGet packages in the same solution:</p>
  
  <blockquote>
    <p>An error occurred while trying to restore packages: The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters.</p>
  </blockquote>