tags:

views:

39

answers:

1

My routes are www.xxxxxxx.com/taxes/us/all-states/all-taxes/2010/q1 and www.xxxxxxx.com/taxes/us/alsalka/all-taxes/

            routes.MapRoute(
            "TaxReport", // Route name
            "taxes/us/{state}/{taxType}/{year}/{quarter}", // URL with parameters
            new
            {
                controller = "TaxViewer",
                action = "TaxReport",
                taxType = "all-taxes",
                year = "",
                quarter = "Q1"
            } // Parameter defaults
        );

When i call <%= Html.RouteLink(state.State, "TaxReport", new { state = state.StateUrlCode, taxType = Model.TaxTypes.SelectedValue })%>

it create alaska i don't know why. Route was working fine when i had "{state}/{taxType}/{year}/{quarter}" but now it is not working.

+2  A: 

I'm not sure what type of output you're expecting but you're not passing in a year and

Html.RouteLink("AK", "TaxReport", new { state="AK", year=2010, taxType="all-taxes" })

with an action like

public ActionResult TaxReport(string taxType, int year, string quarter) {
    return View();
}

seems to work just fine - how is it not working?

BuildStarted
ya because it is optional.
Cruiser KID
Then you should change it to `year = UrlParameter.Optional` and make sure your ActionResult uses `int? year` for a parameter
BuildStarted
actually i noticed your year is a string so you can just use `string year` - hope this works for you :)
BuildStarted