0

I have a URL that is: http://localhost:3018/TestEdit/Index/5/100100/44. But when I click on the link to another page I get this: http://localhost:3018/AnotherPage. I would like it automagically to be this: http://localhost:3018/AnotherPage/Index/5/100100/44. Is there anyway for the Routing system to handle this? Or do I have to explicitly pass the routevalues through the ActionLinks? (That's how I'm doing it now.)

In short, example of best practice (if there is one), please?

dotnetN00b
  • 5,021
  • 13
  • 62
  • 95
  • I'm going to accept @rouen answer as the answer. Since it led me to the actual answer, since it seems [someone had the same problem](http://stackoverflow.com/questions/3779932/mvc-actionlink-add-all-optional-paramters-from-current-url). So this is one of the rare times, where I'll say "this is a duplicate". :) – dotnetN00b Jul 24 '12 at 15:40

2 Answers2

2

Consider creating your own ActionLink extension method to do this - just take current route data from context and call default ActionLink with it.. 3 lines of code, and save you many dirty stuff in views.

rouen
  • 5,003
  • 2
  • 25
  • 48
  • Since you're generally correct and someone on SO had the same problem, I guess you don't have to provide an example anymore. – dotnetN00b Jul 24 '12 at 15:43
1

No, there's no way. You'll have to pass them manually.

Sergei Rogovtcev
  • 5,804
  • 2
  • 22
  • 35