How to prevent SharePoint 2013 app parts from cancelling Minimal Download Strategy (MDS)
Ok, that fiddler trace helps out a lot. You have script in your HTML which is causing the page to revert out of MDS mode.
The code below is the culprit. It is displayed right above the iframe for your app part. You will need to register that code in your code behind using 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>