出于开发目的,我们在IIS7中使用BASIC身份验证进行站点设置。该网站的一个方面是它使用XSLT进行了大量的转换。但是,当在XSLT中加载文档时,这会导致身份验证问题,如下所示:
<xsl:with-param
name="value"
select="document('/mod_cms/xml/fixed/phaedrus_object_menu_display.xml')
/menuDisplay/option[value=$pagingValue]/name"/>
我收到错误:
The remote server returned an error: (401) Unauthorized.
在网上寻找解决方案,我遇到了使用凭证的建议,例如:
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)
但这似乎不起作用。
是否有其他人遇到此问题。
提前感谢您的帮助。