Friday, October 14, 2011

Access denied for Anonymous users with custom xslt

SharePoint Bug

Sometime I had a stress with SharePoint customization, especially on XSLT data transform.
My scenarios is:
- Create a custom view for any list.
- Customize XSLT to render UI for my stituation.
My Problem is:
- With authenticated users, it works fine and smoothly
- Got a notice: Access denied. You do not have permission to perform this action or access this resource for Anonymous users.



I am a "SharePointism", so the first thing I looked into the SharePoint log file. it's very lucky, I got the message: "Error while executing web part: System.UnauthorizedAccessException: Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))     at Microsoft.SharePoint.Library.SPRequest.UpdateWebPartCache(String bstrWebUrl, Boolean bAllUsers, String bstrID, Byte[]& ppsaData, Boolean fOMCall)     at Microsoft.SharePoint.WebPartPages.SPWebPartManager.CacheWriteInternal(Guid storageKey, Byte[] cacheData, Storage storage, Boolean omCall)     at Microsoft.SharePoint.WebPartPages.BaseXsltListWebPart.get_CustomizedXsl()     at Microsoft.SharePoint.WebPartPages.BaseXsltListWebPart.LoadXslCompiledTransform(WSSXmlUrlResolver someXmlResolver)     at Microsoft.SharePoint.WebPartPages.DataFormWebPart.GetXslCompiledTransform()     at Microsoft.SharePoint.WebPartPages.DataFormWebPart.PrepareAndPerformTra..."

Just guess that because I turned on the "Data Web Part Caching" and it seems turned on automatically. So, I disable (remove the checked) for this button. And....oh la la... it still doesn't work. However, we should not do like that because the message from SharePoint is not able to update "Cache". So, I tried to change the value CacheXslStorage="false" and ViewFlag="8", but it still end up with "Access denied".

However, i will work fine if there is an authenticated user view the blog detail first, then everybody can view this post without error. Maybe it's WAD or Bug of SharePoint 2010.

Update: We should not apply the cusomize xslt to ListXsltViewWebPart by UI in toolpane. We should open site by SPD, then change the property named "GhostedXslLink" is our customized xsl. This xsl is in layout/xsl folder of 14/hive. The content of this xsl file has reference to customized xslt.

Hope this help

No comments: