0

.aspxビューを使用しているMVCWebサイトがあります。私はこの方法を使用してビューを見つけています:

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);
    }

マスターページから継承されているビューがあります。その中にはアクションコントローラーへのハイパーリンクがありますが、そのビューはマスターページに接続されていません(私はそれを望まない)。(ハイパーリンクをクリックして)2番目のアクションのビューを表示しようとすると、上記のエラーメッセージが表示されます。他のコンテンツページを指している他のリンクがあり、それらは正常に機能しますが、スタンドアロンの.aspxページ(マスターページから継承されていない)にリンクできません。

何かアドバイス?

4

1 に答える 1

0

空のマスターページを作成するという提案に従ってしまいました。このリンクには詳細な説明があります: http://forums.asp.net/p/1880732/5294074.aspx/1?Re+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-08T15:54:12.643 に答える