是否有可能从内部布局获取视图名称? [英] Is it possible to get the View name from within Layout?

查看:93
本文介绍了是否有可能从内部布局获取视图名称?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从我的布局中拉出当前视图的名称。

I'm trying to pull the name of the current View from within my Layout.

通常情况下, VirtualPath 用于此。不幸的是,这将返回布局文件的路径。

Usually, VirtualPath is used for this. Unfortunately, this will return the path of the Layout file.

有什么办法来获取的控制器返回的视图的名字吗?

Is there any way to get the name of the View that's returned by the controller?

推荐答案

下面将让你的视图名称:

The following will get you the view name:

((RazorView)ViewContext.View).ViewPath;

这篇关于是否有可能从内部布局获取视图名称?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆