SharePoint / ASP.Net Development
Experiences from the field...
Navigation
   RSS 2.0
Categories
Entries by Month

# Monday, January 31, 2005

I wrote in my previous post that you should use http to access web part resources. Well guess what -- there is more to it.

If your WSS site is running with anonymous access off, then the attempt to get the resource will fail with a 401 Unauthorized error. This happens because web requests made in code will perform an anonymous GET.

In my specific case, I was attempting to read an XSLT file from the resource directory by passing the URL to the file. To solve the security issue, the Load() method on the XslTransform object needs a security resolver. The code necessary for this (which I copied from the .Net SDK):

' Build the URI to the resource
Dim resourceURI As Uri = New Uri(ClassResourcePath)
Dim xslPath As String = Path.Combine(resourceURI.ToString(), "filename.xsl")

' Create a secure resolver with default credentials.
Dim resolver as XmlUrlResolver = new XmlUrlResolver()
Dim sResolver as XmlSecureResolver = new XmlSecureResolver(resolver, xslPath)
sResolver.Credentials = CredentialCache.DefaultCredentials

' Get the xsl file
Dim trn As XslTransform = New XslTransform
trn.Load(xslPath, sResolver)

Monday, January 31, 2005 2:14:25 PM (Central Standard Time, UTC-06:00)  #    Comments [0]  | 
Comments are closed.
Search

Further Reading...

Powered by: newtelligence dasBlog 2.2.8279.16125

The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2008, Paul Schaeflein

Send mail to the author(s) E-mail