.net mvc 获取url中controller和action

第一种:

   获取controller名称:ViewContext.RouteData.Values["controller"]

   获取action名称:ViewContext.RouteData.Values["action"]

第二种:

    获取controller名称:ViewContext.Controller.ValueProvider.GetValue("controller").RawValue

   获取action名称:ViewContext.Controller.ValueProvider.GetValue("action").RawValue

posted @ 2013-12-23 14:33  粤木湖  阅读(185)  评论(0)    收藏  举报