這幾天學習使用WebPart,發現眾多問題,使用點滴記錄如下,同各位共用:
1、WebPart的使用必須基於一個通過身分識別驗證的使用者會話。
2、WebPart的使用的個人化應用於所有人的選項預設是禁用的,可以通過修改Web.config來完成
<webParts>
<personalization>
<authorization>
<allow users="*" verbs="enterSharedScope" />
</authorization>
</personalization>
</webParts>
3、WebPart 預設使用頁面的 URL 儲存個人化資料.但是不包含 querystrings,現在要實現在通用的頁面(模版)來實現簡單的門戶系統,通過不同的querystrings來讀取個人,部門等的資料。這樣個人自己設定的設定可以直接和別人共用。這樣的需求在現有的WebPart系統上無法實現,在WebPart Components for Asp.net 2.0: Workspace home URL:http://www.gotdotnet.com/workspaces/workspace.aspx?id=65fa26c3-a62a-49d6-895d-422272e53a0c 有一個這樣的WebPart系統可以滿足需求。這個WebPart的作者介紹:http://fredrik.nsquared2.com/viewpost.aspx?PostID=326
4、啟用WebPart得匯出功能:修改web.config中WebPart的設定
<webParts enableExport="true">
5、匯入自訂的webPart 出現錯誤:Cannot add a control of Type DotnetClubPortal.WebControls.WebParts.RSSReader. The Type must be loadable by BuildManager.GetType(string typeName).
處理辦法:修改web.config檔案:
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<probing privatePath="Bin" />
</assemblyBinding>
</runtime>
http://msdn2.microsoft.com/en-us/library/e0s9t4ck(en-US,VS.80).aspx
1、啟用匿名驗證即可。
<anonymousIdentification enabled="true"/>
3、NSQUARED² 的blog的確不錯,對於Webpart的文章很多。