【问题标题】:Error: Content controls have to be top-level controls in a content page or a nested master page that references a master page错误:内容控件必须是内容页或引用母版页的嵌套母版页中的顶级控件
【发布时间】:2013-02-08 23:54:12
【问题描述】:

我有一个使用 .aspx 视图的 MVC 网站。我正在使用这种方法找到视图:

public override ViewEngineResult FindView(ControllerContext controllerContext, string viewName, string masterName, bool useCache)
    {
        string skinName =
            this.GetSkinName(controllerContext);

        string controllerName =
            controllerContext.RouteData.GetRequiredString("controller");

        string viewPath = 
            this.GetPathFromGeneralName(this.ViewLocationFormats, viewName, controllerName, skinName);

        string masterPath = 
            this.GetPathFromGeneralName(this.MasterLocationFormats, viewName, controllerName, skinName);

        if (string.IsNullOrEmpty(viewPath))
        {
            IEnumerable<string> searchedLocations =
                this.ViewLocationFormats.Union(this.MasterLocationFormats);
            return new ViewEngineResult(searchedLocations);
        }

        return new ViewEngineResult(this.CreateView(controllerContext, viewPath, masterPath), this);
    }

我有一个从母版页继承的视图。在它里面有一个到动作控制器的超链接,但它的视图没有连接到母版页(我不希望它是)。 当它尝试显示第二个操作的视图(通过单击超链接)时,我收到上面的错误消息。 我有其他指向其他内容页面的链接,这些链接工作正常,但我无法链接到独立的 .aspx 页面(不是从母版页继承的)。

有什么建议吗?

【问题讨论】:

    标签: asp.net-mvc


    【解决方案1】:
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多