0

I have an ActionLink that produces this URL

@Html.ActionLink("Hardware Profile", "Profile", "Device", new { id = 2, tab = "hardware"}, null)

//Produces: http://localhost:7946/Device/Profile/2?tab=hardware

But what I want it to produce is:

http://localhost:7946/Device/Profile/2/hardware

I have the following route setup

routes.MapRoute(
                "DeviceProfile",
                "device/profile/{id}/{tab}",
                new { controller = "Device", action = "Profile", id = UrlParameter.Optional, tab = UrlParameter.Optional }
            );

How do I achieve this?

Chris
  • 7,996
  • 11
  • 66
  • 98
  • This is a known issue. See http://stackoverflow.com/questions/4846022/can-anyone-recreate-the-following-bug-im-experiencing-in-routes-with-2-or-more-o and http://haacked.com/archive/2011/02/20/routing-regression-with-two-consecutive-optional-url-parameters.aspx which might give you hints on how to work around it. – Bernie White Sep 19 '11 at 11:04
  • See the links [http://weblogs.asp.net/scottgu/archive/2007/12/03/asp-net-mvc-framework-part-2-url-routing.aspx](http://weblogs.asp.net/scottgu/archive/2007/12/03/asp-net-mvc-framework-part-2-url-routing.aspx) [http://haacked.com/archive/2008/04/22/defining-asp.net-mvc-routes-and-views-in-ironruby.aspx](http://haacked.com/archive/2008/04/22/defining-asp.net-mvc-routes-and-views-in-ironruby.aspx) – Prasanth Sep 19 '11 at 11:09

0 Answers0