How to get route name from action

♀尐吖头ヾ 提交于 2019-12-11 02:34:02

问题


I am using MapMvcAttributeRoutes to set routes in my MVC application. Now I have a doubt is it possible to access a route name from action Index?

[HttpGet]
[Route("{language}/Home/Index", Name = "Home.Index")]
public ActionResult Index()
{
      //access route name Home.Index here?
      return View();
}

I wanted to say I tried something, but do not relly know where to start. I did some researching in forums and SO, but did not find any valid answer.

EDIT

In order to fully understand my question here is an example. Each view contains a partial view (header) that generates links for all languages of a current view. Some actions/views use AttributeRoutes and some use default routing from routeconfig. How can I decide when to call RouteUrl and when to call Action?

来源:https://stackoverflow.com/questions/27402530/how-to-get-route-name-from-action

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!