title: Asp.net MVC 4 Url Resource cannot be found
body: <p>In my Index page I am generating url using the following</p>
  
  <pre><code>@foreach(var c in ViewBag.cities)
  {
     &lt;li&gt;@Html.ActionLink((string)c.CityName,"somepage",new{city=c.CityName, id=c.Id})&lt;/li&gt;
  }
  </code></pre>
  
  <p>Which generated urls for every city in the following format</p>
  
  <pre><code>localhost:55055/1/city1
  localhost:55055/2/city2
  ...
  </code></pre>
  
  <p>where 1,2 are Id and city1, city2 are CityName</p>
  
  <p>I have configured the route as</p>
  
  <pre><code>routes.MapRoute(
              name: "CityRoute",
              url: "{id}/{city}",
              defaults: new { controller = "Home", action = "somepage", id = UrlParameter.Optional, city = UrlParameter.Optional }
              );
  </code></pre>
  
  <p>The <code>somepage</code> action method in Home Controller:</p>
  
  <pre><code>public string somepage(int id, string city)
  {
    return city + " " + id;
  }
  </code></pre>
  
  <p>Even I tried this</p>
  
  <pre><code>public string somepage()
  {
     return "Hello";
  }
  </code></pre>
  
  <p>but it results in <code>Resource cannot be found</code></p>
  
  <p>I tried putting breakpoint in <code>sompage</code> which is never hit.</p>
  
  <p>Any suggesstions</p>
  
  <p><strong>Update</strong></p>
  
  <p>As pointed out by @KD in comments below I changed the routes order and placed above mentioned rule above all rules. I also changed the method</p>
  
  <pre><code> public ActionResult somepage(int id=0, string city="")
   {
      return Content(city + " " + id);
   }
  </code></pre>
  
  <p>Now the behavior changed and the default rule</p>
  
  <pre><code>routes.MapRoute(
              name: "Default",
              url: "{controller}/{action}/{id}",
              defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
          );
  </code></pre>
  
  <p>is not used for normal index page. Instead this use is used since the breakpoint in method <code>somepage</code> is hit and If I put <code>http://localhost:55055/2/cityname</code> in the browser, the page does display id and cityname. But now default route is not used for application home <code>http://localhost:55055/</code></p>