Urlredirect in MVC2
Posted
by Ken
on Stack Overflow
See other posts from Stack Overflow
or by Ken
Published on 2010-02-23T07:39:25Z
Indexed on
2010/04/03
6:43 UTC
Read the original article
Hit count: 390
ASP.NET
|asp.net-mvc-2
In global.asax
routes.MapRoute(
"Test_Default", // Route name
"test/{controller}/{action}", // URL with parameters
new { }
);
routes.MapRoute(
"Default",
"{universe}",
new { controller = "notfound", action = "error"}
);
I have a controller: Home, containing an action: Index Enter the url in browser: h**p://localhost:53235/test/home/index
Inside the index.aspx view in <body> tag: I want to link to the second route.
<%=Html.RouteLink("Link", new { universe = "MyUniverse" })%>
Shouldn't this generate a link to the second route in Global.asax? The generated url from the above is: h**p://localhost:53235/test/home/index?universe=MyUniverse. I can only get it to work, if I specify the name of the route: <%=Html.RouteLink("Link", "default", new { universe = "MyUniverse" })%>
Am I missing something?
© Stack Overflow or respective owner