title: Web API error - Server Error in '/api' Application
body: <p>After publishing Web API to IIS, which is a child of an AngularJs IIS site, I can reach '<a href="https://localhost/api" rel="nofollow noreferrer">https://localhost/api</a>' and see all endpoints; but when I try to reach some specific endpoint with a <code>GET</code> request, I get an error</p>
  
  <blockquote>
    <p>Server Error in '/' Application</p>
  </blockquote>
  
  <pre><code>public class WebApiApplication : System.Web.HttpApplication
  {
      protected void Application_Start()
      {
          AreaRegistration.RegisterAllAreas();
          GlobalConfiguration.Configure(WebApiConfig.Register);
          FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
          RouteConfig.RegisterRoutes(RouteTable.Routes);
          BundleConfig.RegisterBundles(BundleTable.Bundles);
      }
  }
  
  public static class WebApiConfig
  {
      public static void Register(HttpConfiguration config)
      {
          config.SuppressDefaultHostAuthentication();
          config.Filters.Add(new HostAuthenticationFilter(OAuthDefaults.AuthenticationType));
  
          config.MapHttpAttributeRoutes();
  
          config.Routes.MapHttpRoute(
              name: "DefaultApi",
              routeTemplate: "api/{controller}/{id}",
              defaults: new { id = RouteParameter.Optional }
          );
      }
  }
  
  [RoutePrefix("api/branches")]
  public class BranchesController : ApiBaseController
  {
      [HttpGet]
      [Route("getBranches")]
      public async Task&lt;JsonResult&lt;List&lt;BranchDto&gt;&gt;&gt; GetActiveBranches()
      {
          var branches = new List&lt;BranchDto&gt;();
  
          var models = await WarehouseUnitOfWork.BranchRepository.GetActiveBranches();
          if (models != null &amp;&amp; models.Count &gt; 0)
          {
              branches.AddRange(AutoMapper.Mapper.Map&lt;List&lt;Branch&gt;, List&lt;BranchDto&gt;&gt;(models));
          }
  
          return Json(branches, new JsonSerializerSettings
          {
              ContractResolver = new WarehouseCustomContractResolver()
          });
      }
  }
  </code></pre>
  
  <p>Any ideas how to solve this?</p>