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();
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/48235.html
標籤:ASP.NET MVC
上一篇:ASP.NET MVC 中解決api請求引數為空字串時后臺接收為null的問題
下一篇:C#獲取指定目錄下的指定檔案
