Sign in with Microsoft
Sign in or create an account.
Hello,
Select a different account.
You have multiple accounts
Choose the account you want to sign in with.

徵兆

安裝下列其中一種更新後,無法轉譯 Microsoft SharePoint 中有些已建立映像的頁面:

例如,無法轉譯 Microsoft Identity Manager (MIM) 入口網站頁面和透過 SharePoint 解決方案部署的某些自訂頁面。

此外,您可能會遇到下列一個或多個案例。

案例 1

已建立映像的鎖定頁面會顯示下列其中一則錯誤訊息:

  • 此頁面不允許使用屬性「autoeventwireup」。

  • 此頁面不允許使用屬性「enablesessionstate」。

  • 此檔案中不允許使用代碼塊。

  • 此頁面不允許事件處理常式「OnSelectedIndexChanged」。

    附註最後一則錯誤訊息中的事件也可能為其他事件,例如「OnClick」。

            
案例 2

被封鎖的已建立影像頁面顯示下列錯誤訊息:

UnsafeControlException:無法顯示或匯入此頁面上的網頁組件或網頁表單控制項。找不到類型或未註冊為安全類型。

            
案例 3

被封鎖的已建立影像頁面顯示下列錯誤訊息:

此頁面不允許使用參考檔案 '/_layouts/somedirectory/affectedusercontrol.ascx’。

原因

已建立映像的頁面會儲存在檔案系統中。透過禁止伺服器端指令碼和不安全的控制項,增強其安全性等級。如果下列情況成立,可能會封鎖已建立映象的頁面而無法轉譯:

  • 已建立影像頁面包含內聯代碼或伺服器端指令碼。

  • 代碼隱藏類型或網頁組件類型未註冊為安全項目。

案例 1 的解決方案

要解決這個問題,請將具有 VirtualPath 路徑屬性的新 PageParserPath 項目新增至 configuration/SharePoint/SafeMode/PageParserPaths 項目下的 Web.config 檔。

例如,您收到下列錯誤訊息:

「此頁面不允許使用屬性 'autoeventwireup’。」

在此案例中,可以新增一個 PageParserPath 項目,如下所示:

<SafeMode MaxControls="200" CallStack="false" DirectFileDependencies="15" TotalFileDependencies="250" AllowPageLevelTrace="false">
    <PageParserPaths>
        <PageParserPath VirtualPath="/<relativepath>/page.aspx" CompilationMode="Always" AllowServerSideScript="true" AllowUnsafeControls="true"/>
    </PageParserPaths>
</SafeMode>


如果必須解除封鎖同一虛擬目錄中的所有頁面,則可以使用 PageParserPath 項目,如下所示:

<SafeMode MaxControls="200" CallStack="false" DirectFileDependencies="15" TotalFileDependencies="250" AllowPageLevelTrace="false">
    <PageParserPaths>
        <PageParserPath VirtualPath="/<relativepath>/*" CompilationMode="Always" AllowServerSideScript="true" AllowUnsafeControls="true" IncludeSubFolders="True"/>
    </PageParserPaths>
</SafeMode>

  • VirtualPath 是被封鎖頁面的路徑。

  • VirtualPath 必須參考已建立影像且不能被任何用戶解除影像建立的頁面,或包含此頁面的目錄。

  • VirtualPath 參考的頁面必須未參考其他頁面或未建立映象的主版頁面,或者不包含此類頁面或主版頁面的目錄。

  • DirectFileDependencies 表示允許的直接檔案相依性的數目。如果您收到錯誤訊息,例如「允許的直接檔案相依性數目超過限制」,請變更此值。

案例 2 的解決方案

要解決這個問題,請為指定的類型、命名空間和組件的強式名稱在 configuration/SharePoint/SafeControls 項目下的 Web.config 檔中新增 SafeControls 項目,如 SafeControls 項目(解決方案)中所述。然後,將 Safe 屬性設定為 TRUE

如需 SafeControls 項目屬性值格式的詳細資訊,請參閱表格中步驟 12「在套件設計工具中標示安全控制項」一節,有關如何:標示控制項為安全控制項

案例 3 的解決方案

要解決此問題,請在 configuration/SharePoint/SafeControls 項目下的 Web.config 檔中新增一個新的使用 Src 屬性的 SafeControls 項目。

例如您收到下列錯誤訊息:

「此頁面不允許使用參考檔案 '/_layouts/somedirectory/affectedusercontrol.ascx’。」

在此案例中,可以新增一個 SafeControls 項目,如以下範例所示:

< SafeControls>
    <SafeControl Src="~/_layouts/somedirectory/*" IncludeSubFolders="True" Safe="True" AllowRemoteDesigner="True" SafeAgainstScript="True" />
</SafeControls>

< SafeControls> <SafeControl Src="~/_layouts/somedirectory/*" IncludeSubFolders="True" Safe="True" /> </SafeControls>

Need more help?

Want more options?

探索訂閱權益、瀏覽訓練課程、瞭解如何保護您的裝置等等。

社群可協助您詢問並回答問題、提供意見反應,以及聆聽來自具有豐富知識的專家意見。

Was this information helpful?

How satisfied are you with the translation quality?
What affected your experience?
By pressing submit, your feedback will be used to improve Microsoft products and services. Your IT admin will be able to collect this data. Privacy Statement.

Thank you for your feedback!

×