ASP.NET MVC Html.ActionLink Maintains Route Values
Posted
by Carl
on Stack Overflow
See other posts from Stack Overflow
or by Carl
Published on 2010-04-16T08:48:53Z
Indexed on
2010/04/16
8:53 UTC
Read the original article
Hit count: 1153
asp.net-mvc
Hi,
I have a question that has pretty much been asked here:
However, the final solution is a kludge, pure and simple and I really would like to understand why this happens, if someone can please explain it to me?
For completeness, it is possible to recreate the scenario very easily:
- Create a new MVC web app.
- Run it up.
- Visit the About tab Modify the URL to read /Home/About/Flib - This obviously takes you to the action with an id of 'Flib' which we don't care about.
Notice that the top menu link to About now actually links to /Home/About/Flib - this is wrong as far as I can see, as I now have absolutely no way of using site links to get back to /Home/About
I really don't understand why I should be forced to modify all of my Html.ActionLinks to include new { id = string.Empty }
for the routevalues and null for the htmlAttribs. This seems especially out of whack because I already specify id = 0
as part of the route itself.
Hopefully I'm missing a trick here.
© Stack Overflow or respective owner