2 different routes on one page?
Posted
by Dejan.S
on Stack Overflow
See other posts from Stack Overflow
or by Dejan.S
Published on 2010-06-11T08:50:37Z
Indexed on
2010/06/11
8:52 UTC
Read the original article
Hit count: 332
asp.net-mvc
|asp.net-mvc-routing
Hi I'm pretty new with MVC2 or MVC in general. If it's one thing I get caught up with it's routes. Like now I got this scenario. Im going from the regular site to Admin. My navigation is the same partialview on both I just do a check which data to render something like this.
<% if (!Request.RawUrl.Contains("Admin")){%>
<% foreach (var site in Model) { %>
<%= Html.MenuItem(site.BelongSite, "Sida", "Site", site.BelongSite) %> |
<%} %>
<%} else {%>
<%= Html.ActionLink("Konfig", "Konfigurera", "Admin") %>
<% } %>
My route looks like this
routes.MapRoute(
"Admin", // Route name
"Admin/{action}/{name}", // URL with parameters
new { controller = "Admin", action = "konfigurera", name = UrlParameter.Optional } // Parameter defaults
);
On my View called Konfigurera I got Edit sites and they use the route above and it works great. The navigation tho dont get no action assigned to it. It's just <a href='Admin/'>
The navigation is in the shared folder, and it is a strongly typed. Any Ideas? I been struggling with this for about a hour now
Thanks for any input
© Stack Overflow or respective owner