开发者

Loading a document in XSLT using BASIC authentication in ASP.net

开发者 https://www.devze.com 2023-02-15 22:57 出处:网络
For development purposes we have a site setup with BASIC authentication in IIS7. One aspect of the site is that it does a lot transformations using XSLT. However this is causing authentication problem

For development purposes we have a site setup with BASIC authentication in IIS7. One aspect of the site is that it does a lot transformations using XSLT. However this is causing authentication problems when loading documents in XSLT like this:

<xsl:with-param 
     name="value" 
     select="document('/mod_cms/xml/fixed/phaedrus_object_menu_display.xml')
                /menuDisplay/option[value=$pagingValue]/name"/>

I get the error:

The remote server returned an error: (401) Unauthorized.

Looking on the web for solutions, I have come across suggestions to use Credentials, eg:

Dim sw As New StringWriter()
Dim xslArg As New XsltArgumentList()
Dim xslt As New XslCompiledTransform()
Dim settings As New XsltSettings
settings.EnableDocumentFunction = True
Dim resolver As New XmlUrlResolver
Dim xml As New XmlDocument
xml.LoadXml(sXml)

Dim myCache As New System.Net.CredentialCache()
myCache.Add(New Uri("http://URL.net/"), "Basic", New System.Net.NetworkCredential("???", "???"))
myCache.Add(New Uri("http://URL.net/mod_cms/xml/fixed/"), "Basic", 开发者_如何转开发New System.Net.NetworkCredential("???", "???"))
resolver.Credentials = myCache '

xslt.Load(sXsl, settings, resolver)
xslt.Transform(xml, xslArg, sw)

But this doesn't seem to work.

Has someone else had this problem.

Thanks in advance for any help.


Try using an XmlUrlResolver object.

0

精彩评论

暂无评论...
验证码 换一张
取 消