title: asp.net mvc routing: how to use default action but non-default parameter?
body: <p>I'm rewriting the question, as the answers so far show me that I have not defined it good enough. I'll leave the original question for reference below.</p>
  
  <p>When you set up your routing you can specify defaults for different url/route parts. Let's consider example that VS wizard generates:</p>
  
  <pre><code>        routes.MapRoute(
              "Default", // Route name
              "{controller}/{action}/{id}", // URL with parameters
              new { controller = "DefaultPage", action = "Index", id = UrlParameter.Optional } // Parameter defaults
  </code></pre>
  
  <p>In this example if controller is not specified, DefaultPageController will be used and if action is not specified "Index" action will be used.
  The urls will generally look like: <code>http://mysite/MyController/MyAction</code>.</p>
  
  <p>If there is no action in Url like this: <code>http://mysite/MyController</code> then the index action will be used.</p>
  
  <p>Now let's assume I have two actions in my controller Index and AnotherAction. The urls that correspond to them are <code>http://mysite/MyController</code> and <code>http://mysite/MyController/AnotherAction</code> respectively. My "Index" action accepts a parameter, id. So If I need to pass a parameter to my Index action, I can do this: <code>http://mysite/MyController/Index/123</code>. Note, that unlike in URL <code>http://mysite/MyController</code>, I have to specify the Index action explicitly. What I want to do is to be able to pass <code>http://mysite/MyController/123</code> instead of <code>http://mysite/MyController/Index/123</code>. I do not need "Index" in this URL I want the mvc engine to recognize, that when I ask for <code>http://mysite/MyController/123</code>, that 123 is not an action (because I have not defined an action with this name), but a parameter to my default action "Index". How do I set up routing to achieve this?</p>
  
  <p>Below is the original wording of the question.</p>
  
  <hr>
  
  <p>I have a controller with two methods definded like this</p>
  
  <pre><code>    public ActionResult Index()
      {
          return View();
      }
  
      [HttpPost]
      public ActionResult Index(SomeFormData data)
      {
          return View();
  
      }
  </code></pre>
  
  <p>This allows me to process Url like <code>http://website/Page</code> both when the user navigates to this url (GET) and when they subsequently post back the form (POST).</p>
  
  <p>Now, when I process the post back, in some cases I want to redirect the browser to this url:</p>
  
  <pre><code>http://website/Page/123
  </code></pre>
  
  <p>Where 123 is some integer, and I need a method to process this url in my controller.</p>
  
  <p>How do I set up the routing, so this works? Currently I have "default" routing generated by the wizard like this:</p>
  
  <pre><code>        routes.MapRoute(
              "Default", // Route name
              "{controller}/{action}/{id}", // URL with parameters
              new { controller = "DefaultPage", action = "Index", id = UrlParameter.Optional } // Parameter defaults
  </code></pre>
  
  <p>I tried adding another controller method like this:</p>
  
  <pre><code>public ActionResult Index(int id)
  {
      return View();
  }
  </code></pre>
  
  <p>But this doesn't work as ambiguous action exception is thrown:</p>
  
  <blockquote>
    <p>The current request for action 'Index'
    on controller type 'PageController'
    is ambiguous between the following
    action methods: 
    System.Web.Mvc.ActionResult Index() on
    type PageController 
    System.Web.Mvc.ActionResult
    Index(Int32) on type PageController</p>
  </blockquote>
  
  <p>I must add, that I also have other actions in this controller. <a href="https://stackoverflow.com/questions/2512930/asp-net-mvc-routing-help">This</a> would have worked if I didn't. </p>