asp.net mvc - MVC Route Weirdness -
hey all, brand new asp.net mvc , creating fake social site (for learning purposes) building off stock mvc template... added views, etc. work fine. however, have added mvc area called "blog" , added link main menu. if click on of menu items, things work expected - when click on "blog" menu item view, etc show blog page menus links other views have /blog/ in front of url now!? not sure if i'm doing wrong... here menu code:
<div id="menucontainer"> <ul id="menu"> @* @html.actionlink() params = string name, string controller name, string method (actionlink) name *@ <li>@html.actionlink("home", "index", "home")</li> <li>@html.actionlink("mail", "index", "mail")</li> <li>@html.actionlink("search", "index", "search")</li> <li>@html.actionlink("dating", "index", "dating")</li> <li>@html.actionlink("groups", "index", "groups")</li> <li>@html.actionlink("forums", "index", "board")</li> <li>@html.actionlink("blog", "index", "blog")</li> <li>@html.actionlink("about", "about", "home")</li> </ul> </div>
if blog in separate area others, mvc expects links area within same area, appends area url. if in different area, need invoke actionlink "area" route value. instance, if "dating" in "social" area, might use:
@html.actionlink("dating", "index", new { controller = "dating", area = "social" } );
here relevant discussion what’s new in asp.net mvc 2:
“area” reserved route-value key
the string “area” in route values has special meaning in asp.net mvc, in same way “controller” , “action” do. 1 implication if html helpers supplied route-value dictionary containing “area”, helpers no longer append “area” in query string.
if using areas feature, make sure not use {area} part of route url.
Comments
Post a Comment