相关疑难解决方法(0)

如何在ASP.NET MVC中获取控制器中的路由名称?

ASP.NET MVC路由在映射时具有名称:

routes.MapRoute(
    "Debug", // Route name -- how can I use this later????
    "debug/{controller}/{action}/{id}",
    new { controller = "Home", action = "Index", id = string.Empty } );
Run Code Online (Sandbox Code Playgroud)

有没有办法获取路由名称,例如上面的例子中的"Debug"?我想在控制器的OnActionExecuting中访问它,以便我可以在调试时在ViewData中设置内容,例如,通过在/ debug /前面添加一个URL ...

model-view-controller asp.net-mvc routing

53
推荐指数
1
解决办法
3万
查看次数