title: ASP.NET MVC 4 Routing Query - Passing query-string to Index Action
body: <p>I have a controller with an index action.</p>
  
  <pre><code>public ActionResult Index(int id = 0)
  {
  
      return view();
  }
  </code></pre>
  
  <p>I wish to pass id into the index action, however it doesnt appear to work in the same way as the details action.</p>
  
  <p>e.g. if I want to pass id 4 into the index action, I have to visit url:</p>
  
  <pre><code>http://localhost:8765/ControllerName/?id=4
  </code></pre>
  
  <p>With the details Action... I can do this.</p>
  
  <pre><code>http://localhost:8765/ControllerName/Details/4
  </code></pre>
  
  <p>What I want to do with Index is something like...</p>
  
  <pre><code>http://localhost:8765/ControllerName/4
  </code></pre>
  
  <p>When I visit this url, I get an error:</p>
  
  <pre><code>Server Error in '/' Application.
  
  The resource cannot be found.
  
  Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable.  Please review the following URL and make sure that it is spelled correctly. 
  
  Requested URL: /fix/1
  
  Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.17929
  </code></pre>
  
  <p>Is this possible? How can I get MVC to automatically treat the index action in the same way as the details one?</p>
  
  <p>Thanks</p>
  
  <p>UPDATE - MY CURRENT ROUTES CONFIG</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>UPDATE NEW RouteConfig Class still doesn't work when I visit localhost:1234/Fix/3</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 }
          );
  
              routes.MapRoute(
              name: "FixIndexWithParam",
              url: "Fix/{id}",
              defaults: new { controller = "Fix", action = "Index", id = UrlParameter.Optional });
      }
  }
  </code></pre>