- A+
所属分类:.NET技术
protected String RouteController { get { return GetRouteData("controller"); } } protected String RouteAction { get { return GetRouteData("action"); } } protected String RouteID { get { return GetRouteData("id"); } } protected String GetRouteData(String key) { if (String.IsNullOrEmpty(key)) return null; // Mvc 都是使用小写字母 key = key.ToLower(); IDictionary<string, object> routeValues = this.ControllerContext.RouteData.Values; if (!routeValues.ContainsKey(key)) return null; return routeValues[key].ToString(); }