views:

557

answers:

3

So I have a custom route as such:

routes.MapRoute(
       "Wizard", // Route name
       "Wizard/{page}", // URL with parameters
       new { controller = "Wizard", action = "Index" }  // Parameter defaults
     );

and have the following on my View:

<% Html.BeginForm("Continue", "Wizard"); %>
    <input type="submit" value="Continue" name="Continue" />
<% Html.EndForm(); %>

In which I want to call this function:

    [AcceptVerbs(HttpVerbs.Post)]
 public ActionResult Continue(string Number, string Rev)
 {
        (...)
    }

but in turn when that button is pressed always calls the postback Index rather than the one I want. If I remove the custom route, it calls my function, but what I want to be displayed in the address bar is: localhost:xxxx/Wizard/1 where the number at the end is the page (div shown) of the wizard either 1, 2, 3, or 4. So is there something I'm missing or can it not be done? Thanks.

A: 

Your custom route should be placed before the default one.

CD
It is placed before.
dangerisgo
A: 

You should change your route so that action is the parameter:

routes.MapRoute(
  "Wizard", // Route name
  "Wizard/{action}", // URL with parameters
  new { controller = "Wizard", action = "Index"}  // Parameter defaults
);

Regarding the rest of your question, please can you elaborate?

Dan Atkinson
A: 

What's being written out in your HTML right now (the form tag)?

Where do you expect the page number to come from? I don't see how you're trying to make it part of the URL. (And since it's not part of the URL, it causes the route not to match.) You need to make it part of the route, like:

<%= Html.BeginForm("Continue", "Wizard", new { page = intPage }) %>

Also, I'm not positive that the default for FormMethod is POST. You might want to double-check that in the form tag.

James

James S