標籤:des style class blog code http
在之前的SharePoint網站iframe引用中,我們遇到過下面的問題,就是其它系統或者不通環境的SharePoint網站,引用SharePoint頁面會報錯“此內容不能顯示在一個架構中”,之前我們採取瞭解決方案的辦法。
今天,無意中翻看msdn,發現了更加簡便的方法,分享給大家。
原理介紹
在大部分情況下,如果網頁在響應中發送 X-Frame-Options HTTP 頭,則該網頁將無法在架構中顯示。預設情況下,SharePoint 網頁包含 X-Frame-Options 頭。如果使用應用程式 Web 承載的 SharePoint 網頁,您可能會遇到以下錯誤(如所示):"此內容無法在架構中顯示"。
This content cannot be displayed in a frame
To help protect the security of information you enter into this website, the publisher of this content does not allow it to be displayed in a frame.
What you can try:Open this content in a new window
請記住,當網頁在架構中顯示時,特定方案易受"點擊劫持"攻擊。請仔細評估您的應用程式組件方案,以確保不存在點擊劫持攻擊風險。
如果在應用程式 Web 中承載的頁面不易受點擊劫持攻擊,則您可以使用 AllowFraming Web 組件抑制頁面響應中的 X-Frame-Options 頭。下面的程式碼範例展示如何在 SharePoint 頁面中使用 AllowFraming Web 組件。
<webpartpages:allowframing id="AllowFraming1" runat="server"/>
解決方案
使用SharePoint Designer開啟該頁面(特別的,修改的是要被iframe方式引用的頁面)的頁面配置,加入如代碼:
特別要說的是,WebPartId會自動產生,不需要我們手動添加;
再次開啟頁面,發現iframe的頁面顯示正常了,不再報錯,如:
參考連結
http://www.cnblogs.com/jianyus/p/3385514.html
http://msdn.microsoft.com/ZH-CN/library/office/fp179921(v=office.15).aspx