6

SharePoint 2013 Online (オンプレミスでのテストは行っていません) でのページの読み込みが、MDS からアプリ パーツを含むすべてのページの全ページ読み込みにフォールバックすることがわかりました。

これは、SharePoint がホストするアプリ パーツとプロバイダーがホストするアプリ パーツの両方に当てはまることがわかりました。

スクリプト リンクなどの既知の問題が原因ではないことを確認するために、基本的な html コンテンツ以外をすべて削除してページを簡略化しました。

テストの一環として、MDSがサイトの他のページで機能していることを確認しました (例: あるドキュメント ライブラリから別のドキュメント ライブラリへの移動)。

MDS フォールバックに関する記事をいくつか読みましたが、

しかし、 app parts が MDS をキャンセルすると言う人は誰も見たことがありません

ここに私が有用だと思ったいくつかの投稿があります。

http://steve.thelineberrys.com/gotchas-using-custom-web-parts-and-the-minimal-download-strategy/ http://www.wictorwilen.se/sharepoint-2013---introduction-to-最小限のダウンロード戦略 mds

編集: MDS フォールバックのフィドラー トレースを作成しました。応答の一部として生成されたエラーは表示されません。トレースはhttp://1drv.ms/1pWrlx3でダウンロードできます。

4

2 に答える 2

5

わかりました、そのフィドラー トレースは大いに役立ちます。HTML にスクリプトが含まれているため、ページが MDS モードから戻ります。

以下のコードが原因です。アプリ パーツの iframe のすぐ上に表示されます。SPPageContentManager.RegisterClientScriptBlock を使用して、コード ビハインドでそのコードを登録する必要があります。

<script type='text/javascript'>
    var spAppIFrameSenderInfo = new Array(1);
    var SPAppIFramePostMsgHandler = function(e)
    {
        if (e.data.length > 100)
            return;

        var regex = RegExp(/(<\s*[Mm]essage\s+[Ss]ender[Ii]d\s*=\s*([\dAaBbCcDdEdFf]{8})(\d{1,3})\s*>[Rr]esize\s*\(\s*(\s*(\d*)\s*([^,\)\s\d]*)\s*,\s*(\d*)\s*([^,\)\s\d]*))?\s*\)\s*<\/\s*[Mm]essage\s*>)/);
        var results = regex.exec(e.data);
        if (results == null)
            return;

        var senderIndex = results[3];
        if (senderIndex >= spAppIFrameSenderInfo.length)
            return;

        var senderId = results[2] + senderIndex;
        var iframeId = unescape(spAppIFrameSenderInfo[senderIndex][1]);
        var senderOrigin = unescape(spAppIFrameSenderInfo[senderIndex][2]);
        if (senderId != spAppIFrameSenderInfo[senderIndex][0] || senderOrigin != e.origin)
            return;

        var width = results[5];
        var height = results[7];
        if (width == "")
        {
            width = '300px';
        }
        else
        {
            var widthUnit = results[6];
            if (widthUnit == "")
                widthUnit = 'px';

            width = width + widthUnit;
        }

        if (height == "")
        {
            height = '150px';
        }
        else
        {
            var heightUnit = results[8];                        
            if (heightUnit == "")
                heightUnit = 'px';

            height = height + heightUnit;
        }

        var widthCssText = "";
        var resizeWidth = ('False' == spAppIFrameSenderInfo[senderIndex][3]);
        if (resizeWidth)
        {
            widthCssText = 'width:' + width + ' !important;';
        }

        var cssText = widthCssText;
        var resizeHeight = ('False' == spAppIFrameSenderInfo[senderIndex][4]);
        if (resizeHeight)
        {
            cssText += 'height:' + height + ' !important';
        }

        if (cssText != "")
        {
            var webPartInnermostDivId = spAppIFrameSenderInfo[senderIndex][5];
            if (webPartInnermostDivId != "")
            {
                var webPartDivId = 'WebPart' + webPartInnermostDivId;

                var webPartDiv = document.getElementById(webPartDivId);
                if (null != webPartDiv)
                {
                    webPartDiv.style.cssText = cssText;
                }

                cssText = "";
                if (resizeWidth)
                {
                    var webPartChromeTitle = document.getElementById(webPartDivId + '_ChromeTitle');
                    if (null != webPartChromeTitle)
                    {
                        webPartChromeTitle.style.cssText = widthCssText;
                    }

                    cssText = 'width:100% !important;'
                }

                if (resizeHeight)
                {
                    cssText += 'height:100% !important';
                }

                var webPartInnermostDiv = document.getElementById(webPartInnermostDivId);
                if (null != webPartInnermostDiv)
                {
                    webPartInnermostDiv.style.cssText = cssText;
                }
            }

            var iframe = document.getElementById(iframeId);
            if (null != iframe)
            {
                iframe.style.cssText = cssText;
            }
        }
    }

    if (typeof window.addEventListener != 'undefined')
    {
        window.addEventListener('message', SPAppIFramePostMsgHandler, false);
    }
    else if (typeof window.attachEvent != 'undefined')
    {
        window.attachEvent('onmessage', SPAppIFramePostMsgHandler);
    }spAppIFrameSenderInfo[0] = new Array("EC5C9C4B0","g_8282237a_000e_4ab0_baf6_a4ad64ccc6ba","http:\u002f\u002fapp-bda070359d354c.apps","False","False","ctl00_ctl33_g_1581e83c_d38c_4be0_81eb_1015c2ac7a1b");
</script>
于 2014-04-03T20:12:13.163 に答える
0

このトピックに対処している Sean Hesters による次の記事が、この質問に答えるのに非常に役立つことがわかりました: SharePoints MDS の使用と周辺

...SharePoint ホスト型またはプロバイダー ホスト型ソリューション用の SharePoint 2013 アプリ パーツを開発している場合、現時点での MDS の話は暗いものです。これを書いている時点では、SharePoint がページに埋め込まれたアプリ パーツをレンダリングするために使用するコントロールが原因で、MDS が失敗します: Every. 独身。時間。失敗するだけでなく、失敗の原因は SharePoint の内部構造にあるようです。App Parts MDS に準拠させることでこれを解決する方法はありません。.NET Reflector を使用して SharePoint 2013 のソースを調べたところ、アプリ パーツのレンダリングに使用される SPAppIFrame コントロールが、HtmlTextWriter クラスを使用して raw タグを発行していることがわかりました。これにより、上記の Microsoft 独自の推奨事項に従って、SPAppIFrame コントロールは MDS に準拠しなくなります。この問題に関する詳細な技術情報は、同僚の Eric Bowden による StackOverflow の投稿で確認できます。ThreeWill は、この問題を調査するために SharePoint Online チームとのサポート チケットをオープンしていますが、おそらく簡単な解決策ではないため、すぐに解決できるとは考えていません。残念ながら、現時点では Hosted Solution の開発者に多くの選択肢が残されていません:

  1. アプリ パーツの代わりにアプリを使用します。
  2. start.aspx を使用して、MDS に準拠していないページに要求をルーティングしないようにします。
  3. SharePoint Web で MDS 機能を無効にします。

なので、基本的にはできません。サイト ページにアプリ パーツを配置する必要がある場合は、Minimal Download Strategy (MDS) を無効にすることをお勧めします。これは、MDS がページで実行された後に強制的にダウンロードが行われるためです。

于 2019-05-02T20:43:58.560 に答える