确定视图的“嵌套级别" [英] Determine view 'nesting level'

查看:55
本文介绍了确定视图的“嵌套级别"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不确定我是否在帖子标题中使用写术语.

I'm not sure if I'm using the write terminology in the title of this post.

我有一个视图,用于呈现表单中的日志.有时,视图是通过控制器以标准方式自行呈现的,而有时,它会使用以下内容嵌入到另一个视图中.

I have a view that is used to render a log in form. Sometimes the view is rendered on it's own via a controller in the standard way, other times it is embedded inside another view using the following.

@if(!Request.IsAuthenticated) {
            Html.RenderAction("LogOn", "Account");
         }

我需要一种方法来确定子"视图(登录面板)中是否使用RenderAction调用了另一个视图,以便可以禁用其Layout属性.

I need a way to determine within the 'child' view (the logon panel) if it has been called by another view using RenderAction, so that it can disable its Layout property.

有什么秘诀吗?我正在考虑一些检查路由值以查看它们是否与子"视图匹配的方法...但是我不确定如何执行此操作.

Any tips? I'm thinking something along the lines of checking the routing values to see if they match the 'child' view... but I'm not sure how to do this.

非常感谢,

Z

推荐答案

您可以尝试使用 ControllerContext.IsChildAction .

这篇关于确定视图的“嵌套级别"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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