【问题标题】:How to switch master page depending on IFrame如何根据 IFrame 切换母版页
【发布时间】:2008-12-24 22:58:58
【问题描述】:

我想在我的 ASP.Net MVC 应用程序中使用 IFrame,但我想在通过直接访问(搜索引擎)导航内部页面时保留布局。

如何根据视图是在 IFrame 还是顶级窗口中切换母版页?

【问题讨论】:

    标签: asp.net-mvc iframe


    【解决方案1】:

    您在控制器 Action 中返回的 ViewResult 具有 MasterName 属性。 让您的控制器操作接收一个参数,告诉它您是否在 IFrame 中,然后您可以执行

    if (isInIFrame)
    {
        ViewResult result = View();
        result.MasterName = "IFrameMaster";
        return result;
    }
    

    【讨论】:

      【解决方案2】:

      一种方式:

      将内容放在用户控件中。编写一个轻量级视图,其中包含 IFrame 版本的用户控件和顶级版本的另一个。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2017-03-03
        • 1970-01-01
        相关资源
        最近更新 更多