我已经发现,SharePoint 2013在线页面加载(还没有在prem上测试)会从MDS返回到包含应用程序部件的任何页面的完整页面加载。
我发现SharePoint托管的应用程序部件和提供商托管的应用程序部件都是如此。
我已经简化了页面,以删除所有的,但只是基本的html内容,以确保一些已知的问题,如脚本链接,没有造成问题。
作为测试的一部分,我确认了MDS正在为站点上的其他页面运行(例如:从一个文档库导航到另一个文档库)。
我读过几篇关于MDS撤退的文章,
但是我还没见过有人提到应用程序部件会取消MDS。
这里有几篇我觉得有用的帖子。
http://steve.thelineberrys.com/gotchas-using-custom-web-parts-and-the-minimal-download-strategy/ http://www.wictorwilen.se/sharepoint-2013---introduction-to-the-minimal-download-strategy-mds
编辑:我创建了MDS回退的小提琴跟踪。我没有看到在响应中产生任何错误。跟踪可以在http://1drv.ms/1pWrlx3下载。
发布于 2014-04-03 20:12:13
好吧,那个小提琴手的追踪很有帮助。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>发布于 2019-05-02 20:43:58
我发现以下由Sean撰写的关于这个主题的文章对于回答这个问题非常有帮助:使用和围绕SharePoints MDS
...if您正在为SharePoint托管或提供商托管的解决方案开发SharePoint 2013应用程序部件,目前MDS的情况是黯淡的。在我编写这篇文章时,SharePoint用于在页面上呈现嵌入式应用程序部件的控件导致MDS失败:所有。单人。时间到了。它不仅失败了,而且这个故障似乎是由SharePoint的内部结构引起的;没有办法通过使appears兼容来解决这个问题。我们使用SharePoint Reflector深入研究了.NET 2013源代码,发现用于呈现App的SPAppIFrame控件使用HtmlTextWriter类发出原始标记。这使得SPAppIFrame控件不符合上面列出的微软自己的建议。您可以在我的同事Eric关于这个问题的StackOverflow文章中找到有关这个问题的详细技术信息。ThreeWill向SharePoint在线团队开放了一张支持票,以调查这个问题,但这可能不是一个容易解决的问题,因此我们并不期待很快就会有一个解决方案。不幸的是,这给宿主解决方案开发人员留下了很多选择:
所以基本上你不能这么做。如果您必须在您的站点页面中有应用程序部件,您最好只是禁用最小下载策略( MDS ),因为MDS将强制在您的页面中运行之后发生这种情况。
https://stackoverflow.com/questions/22693351
复制相似问题