title: ASP.NET WebApi not working. All routes return 404
body: <p>I have an asp.net web api with <code>Unity</code> as my dependency resolver and <code>OWIN</code> for OAuth authentication.</p>
  
  <p>I create a <code>Startup.cs</code> using the Visual Studio "Add New Item"-menu, choosing <strong>OWIN Startup class</strong>:</p>
  
  <pre><code>[assembly: OwinStartup(typeof(MyNameSpace.Startup))]
  namespace MyNameSpace
  {
      public class Startup
      {
          public void Configuration(IAppBuilder app)
          {
              var config = new HttpConfiguration();
              WebApiConfig.Register(config);
              config.DependencyResolver = new UnityHierarchicalDependencyResolver(UnityConfig.GetConfiguredContainer());
              app.UseWebApi(config);
          }
      }
  }
  </code></pre>
  
  <p>My <code>WebApiConfig.cs</code> looks like this:</p>
  
  <pre><code>public static void Register(HttpConfiguration config)
  {
      // Web API configuration and services
      config.SuppressDefaultHostAuthentication();
      config.Filters.Add(new HostAuthenticationFilter(OAuthDefaults.AuthenticationType));
  
      // Web API routes
      config.MapHttpAttributeRoutes();
  
      config.Routes.MapHttpRoute(
          name: "DefaultApi",
          routeTemplate: "api/{controller}/{id}",
          defaults: new { id = RouteParameter.Optional }
      );
  }
  </code></pre>
  
  <p>Now, when I start the application I get a <strong>Forbidden</strong> response for the default url which is <code>http://localhost:port/</code>. The web api is hosted at <code>http://localhost:port/api/</code>. When I make a request for this url or <strong>any</strong> controller in the application it responds with <strong>Not Found</strong>.</p>
  
  <p>Additionally, when I put a breakpoint in the <code>Configuration</code> method of the <code>Startup</code> class; once I start up the application it displays the following (I don't know if it is relevant):</p>
  
  <p><img src="https://i.stack.imgur.com/agipO.png" alt="message"></p>
  
  <p>I can't figure out what's wrong. It worked last night and I'm the only one who has been working on this project. The only thing I've done is add <code>OData</code> references from <code>NuGet</code>, but I removed those again once I established that the api was not working.</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>I should add that <em>any</em> breakpoint I set in the application currently displays the same message when I hover over it, so maybe it is relevant after all.</p>
  
  <p><strong>EDIT 2:</strong></p>
  
  <p>This is an excerpt from <code>EmployeeController.cs</code>:</p>
  
  <pre><code>[Authorize]
  public class EmployeeController : ApiController
  {
      private readonly IEmployeeService _service;
  
      public EmployeeController(IEmployeeService employeeService)
      {
          _service = employeeService;
      }
  
      [HttpGet]
      [ResponseType(typeof(Employee))]
      public IHttpActionResult GetEmployee(string employeeId)
      {
          var result = _service.GetEmployees().FirstOrDefault(x =&gt; x.Id.Equals(employeeId));
          if (result != null)
          {
              return Ok(result);
          }
          return NotFound();
      }
  
      [HttpGet]
      [ResponseType(typeof (IQueryable&lt;Employee&gt;))]
      public IHttpActionResult GetEmployees()
      {
          return Ok(_service.GetEmployees());
      }
  ...
  </code></pre>
  
  <p><strong>EDIT 3</strong></p>
  
  <p>After restarting Visual Studio as suggested I can confirm that the breakpoint warning persists and shows up accross the entire application:</p>
  
  <p><img src="https://i.stack.imgur.com/7gO5y.png" alt="breakpoint in controller"></p>
  
  <p><strong>EDIT 4</strong></p>
  
  <p>Removing <code>OWIN</code> references and <code>Startup.cs</code>, the application now springs back into life. I am able to place breakpoints again and make api calls. What's going on?</p>