title: ASP.NET Root Url Doesn't Resolve to Default.aspx
body: <p>I have an asp.net web site that won't seem to resolve to Default.aspx when initially loading. When I debug on my local machine it loads Default no problem. Unless I try to navigate to "localhost:#####/". Then it gives a 404 error. When I deploy it to a staging server, give it a virtual path "mywebapp", and load it from "mydomain.com/mywebapp" it gives a 404 as well. I have set Default.aspx to the top of the list for Default Document in IIS. If I navigate to "mydomain.com/mywebapp/default" the site loads just fine. Any suggestions? I would paste code but it is a large website and I quite honestly am not sure what I'm looking for anymore.</p>
  
  <p><a href="https://i.stack.imgur.com/MB9Ww.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/MB9Ww.png" alt="enter image description here"></a></p>
  
  <p>EDIT:
  In my site I am also using DataTables for display and edit of data. In the ajax calls I was previously able to call the controller by using urls such as:</p>
  
  <pre><code>api/MyController/idvalue
  </code></pre>
  
  <p>but since uncovering this I had to go back and preface the urls to get them to work:</p>
  
  <pre><code>mywebapp/api/MyController/idvalue
  </code></pre>
  
  <p><strong>Controller:</strong></p>
  
  <pre><code>public class MyController : ApiController
  {
      [Route("api/MyContoller/{idvalue}")]
      [HttpGet]
      [HttpPost]
      public IHttpActionResult MyControllerMethod(intidvalue)
      {
      }
  }
  </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 static class RouteConfig
  {
      public static void RegisterRoutes(RouteCollection routes)
      {
          var settings = new FriendlyUrlSettings();
          settings.AutoRedirectMode = RedirectMode.Permanent;
          routes.EnableFriendlyUrls(settings);
  
          routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
  
          //routes.MapRoute(
          //        name: "Default",
          //        url: "{controller}/{action}/{id}",
          //        defaults: new { action = "Index", id = UrlParameter.Optional }
          //    );
          routes.MapRoute(
              name: "Default",
              url: "{controller}/{action}/{id}",
              defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
          );
      }
  }
  </code></pre>