我是新來MVCSiteMap,我有一個簡單的問題:如何配置MVCSiteMap來實現參數?
我使用的是默認路由的配置是這樣的:
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional });
在我的控制器
現在,我想創建和編輯實體同樣的動作:
public ActionResult AddEdit(int? id)
{}
所以如果id爲null,則意味着加,如果不爲空,則操作是編輯。
現在我想讓網站地圖實現不同於添加和編輯。我試過這個:
<mvcSiteMapNode title="Parent" controller="Class" action="Index">
<mvcSiteMapNode title="Add" controller="Class" action="AddEdit" />
<mvcSiteMapNode title="Edit" controller="Class" action="AddEdit" inheritedRouteParameters="Id"/>
</mvcSiteMapNode>
但似乎不能很好地工作。它總是使用第二個。
我該怎麼辦? 非常感謝。