获取控制器和操作方法的名称在ASP.Net MVC视图 [英] Getting the name of the controller and action method in the view in ASP.Net MVC
本文介绍了获取控制器和操作方法的名称在ASP.Net MVC视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有在ASP.Net MVC视图的方式来获取正在使用的视图的控制器和actien方法的名字呢?
Is there a way in a view in ASP.Net MVC to get the names of the controller and actien method that are using the view?
推荐答案
试试这个:
<%= ViewContext.RouteData.Values["Controller"] %>
<%= ViewContext.RouteData.Values["Action"] %>
这篇关于获取控制器和操作方法的名称在ASP.Net MVC视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文