我如何才能找到那个叫我的MVC3视图控制器动作的名称? [英] How can I find out the name of the controller action that called my view in MVC3?
本文介绍了我如何才能找到那个叫我的MVC3视图控制器动作的名称?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想code一些逻辑到我的观点,即取决于用于调用视图控制器动作的名称。有没有一种方法,我可以找到这个名字。
I would like to code some logic into my views that depends on the name of the controller action used to call the view. Is there a way I can find out this name.
希望有人能帮助我这一点。请注意,这是MVC3我使用。
Hope somebody can help me with that. Please note that it's MVC3 I am using.
推荐答案
获取控制器的名称
@ViewContext.Controller.ValueProvider.GetValue("controller").RawValue
获取动作的名称
@ViewContext.Controller.ValueProvider.GetValue("action").RawValue
我发现,<一个href=\"http://blog.janjonas.net/2011-02-15/aspnet-mvc_3-get-controller-action-razor-view\">here.
这篇关于我如何才能找到那个叫我的MVC3视图控制器动作的名称?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文