ActionName Attribute & UrlHelper.Action Method in ASP.NET MVC

I use the ActionName Attribute for enabling a dash in the URL:

[ActionName("My-Action")]
public ActionResult MyAction() {
    return View();
}

It works fine. But it don't work when I generate links for the navigation-menu:

Link = new UrlHelper(HttpContext.Current.Request.RequestContext).Action(MVC.Area.Controller.MyAction())

The generated Link on the Website is always without the dash.

Does anybody have a solution?


@dime2lo: Thank you for your tip! It works with: .Action("My-Action", "Controller", new { area = "Area"})

链接地址: http://www.djcxy.com/p/23366.html

上一篇: gcc)当它明显存在时不存在

下一篇: ASP.NET MVC中的ActionName属性和UrlHelper.Action方法