title: ASP.NET MVC 3 url routing
body: <p>I'm having some trouble grasping MVC routing. I've read and read and it still doesn't make much sense. I'm trying to map the route "Teams/Summary?teamID=30" so that it displays "Teams/30" in the browser. This is what I have at the moment but I can't understand why it doesn't work:</p>
  
  <pre><code>//Teams routes
  routes.MapRoute(
          "TeamsSummary",
          "Teams/{teamID}",
          new { controller = "Teams", action = "Index", teamID = UrlParameter.Optional }
      );
  </code></pre>
  
  <p>By "doesn't work", I mean that the webpage loads but it still displays "Teams?teamID=30" in the browser address bar.</p>
  
  <p>Could someone help me to understand what I need to do to perform such a simple mapping? By the way, I don't have any other routes set up that I think would interfere and it is listed before the default route in my Global.asax.cs file.</p>
  
  <p>If you have some good articles and tutorials for this subject, that would be helpful as well. Thanks.</p>
  
  <p><strong>Edit:</strong>
  The route works fine if I type the URL in manually. The problem now occurs when I use a form to post back to the controller:</p>
  
  <p>Controller:</p>
  
  <pre><code>public ActionResult Index(TeamsViewModel model)
      {
          if (model.teamID != null)
              model.TeamSummary = new TeamSummaryViewModel(model.teamID);
  
          return View(model);
      }
  </code></pre>
  
  <p>View:</p>
  
  <pre><code>@{
  ViewBag.Title = "Teams";
  }
  
  @using (Html.BeginForm("Index","Teams",FormMethod.Get))
  {
      @Html.DropDownList("teamID", new SelectList(Model.Teams,"teamID","Name"))    
      &lt;input type="submit" value="Filter"/&gt;
  }
  @if (Model.TeamSummary != null)
  {
      Html.RenderPartial("_TeamSummary", Model.TeamSummary);
  }
  </code></pre>
  
  <p><strong>Edit2:</strong>
  Changed the original action to the Index on the TeamsController rather than Summary as it was previously.</p>