Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
从 http 上下文类中是否有获取当前控制器名称的方法?
是的,你可以做这样的事情
HttpContext.Current.Request.RequestContext.RouteData.Values["controller"].ToString();
如果您在视图中,则可以执行以下操作:
ViewContext.RouteData.Values["Controller"]