我在控制器中有一个动作:
public ActionResult Close(DocType docType)
{
return View();
}
其中 DocType 是一个简单的枚举。我想有 2 个不同的链接指向相同的操作,但参数不同。我试过这个:
<mvcSiteMapNode title="Accounting" clickable="false" imageUrl="~/Content/Images/Buttons/MenuButtons/billing.png" visibility="path">
<mvcSiteMapNode title="Payments" controller="Payment" action="Index"></mvcSiteMapNode>
<mvcSiteMapNode title="Closing WO" controller="Payment" action="Close" docType="2"></mvcSiteMapNode>
<mvcSiteMapNode title="Closing WS" controller="Payment" action="Close" docType="4"></mvcSiteMapNode>
</mvcSiteMapNode>
但在菜单中,我有 2 个没有任何参数的链接:“/Payments/Close”
怎么了?如何在 mvcSiteMapNode 中添加参数?
这是我的RouteConfig:
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
}