<p>I'm using ASP.NET MVC Preview 4 and would like to know how to use the routing engine for form submissions.</p>

<p>For example, I have a route like this:</p>

<pre><code>routes.MapRoute(
            "TestController-TestAction",
            "TestController.mvc/TestAction/{paramName}",
            new { controller = "TestController", action = "TestAction", id = "TestTopic" }
            );
</code></pre>

<p>And a form declaration that looks like this:</p>

<pre><code>&lt;% using (Html.Form("TestController", "TestAction", FormMethod.Get))
   { %&gt;
     &lt;input type="text" name="paramName" /&gt;
     &lt;input type="submit" /&gt;
&lt;% } %&gt;
</code></pre>

<p>which renders to:</p>

<pre><code>&lt;form method="get" action="/TestController.mvc/TestAction"&gt;
  &lt;input type="text" name="paramName" /&gt;
  &lt;input type="submit" /&gt;
&lt;/form&gt;
</code></pre>

<p>The resulting URL of a form submission is:</p>

<pre><code>localhost/TestController.mvc/TestAction?paramName=value
</code></pre>

<p>Is there any way to have this form submission route to the desired URL of:</p>

<pre><code>localhost/TestController.mvc/TestAction/value
</code></pre>

<p>The only solutions I can think of are to create a separate action that just checks the request parameters, or to use Javascript.</p>

[{'answer_id': 8495, 'author': 'Haacked', 'author_id': 598, 'author_profile': 'https://Stackoverflow.com/users/598', 'pm_score': 2, 'selected': False, 'text': "<p>In your route, get rid of the {paramName} part of the URL. It should be:</p>\n\n<p>TestController.mvc/TestAction</p>\n\n<p>As that is the URL you want the request to route to. Your form will then post to that URL. \nPosted form values are mapped to parameters of an action method automatically, so don't worry about not having that data passed to your action method.</p>\n"}, {'answer_id': 32361, 'author': 'Haacked', 'author_id': 598, 'author_profile': 'https://Stackoverflow.com/users/598', 'pm_score': 2, 'selected': False, 'text': '<p>My understanding is that this is how HTML works. If you do a <code>&lt;form url="foo" method="get"&gt;</code> and post the form, then the form will post foo?</p>\n\n<pre><code>param1=value1&amp;...&amp;paramn=valuen\n</code></pre>\n\n<p>It has nothing to do with MVC.</p>\n\n<p>Besides, what part of REST does that URL violate? It\'s not a <strong>pretty</strong> URL, but by strict definition of REST, it can be RESTful. REST doesn\'t specify that query parameters have to be in an URL segment. And in this case, those are query parameters.</p>\n'}, {'answer_id': 49184, 'author': 'Matt Mitchell', 'author_id': 364, 'author_profile': 'https://Stackoverflow.com/users/364', 'pm_score': 4, 'selected': True, 'text': '<p>Solution:</p>\n\n<pre><code>public ActionResult TestAction(string paramName)\n{\n    if (!String.IsNullOrEmpty(Request["paramName"]))\n    {\n        return RedirectToAction("TestAction", new { paramName = Request["paramName"]});\n    }\n    /* ... */\n}\n</code></pre>\n'}]
['https://Stackoverflow.com/questions/8485', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/364/']