1、視圖中
string controller = ViewContext.RouteData.Route.GetRouteData(this.Context).Values["controller"].ToString(); string controller = ViewContext.RouteData.Values["controller"].ToString();
中
例如在ActionFilterAttribute中,這個時候一般是自己實作一個繼承
類,然後重寫相關的方法。string controller = RouteData.Route.GetRouteData(this.HttpContext).Values["controller"].ToString(); string controller = RouteData.Values["controller"].ToString();