bujjigadu
asked on
WebException: The remote server returned an error: (401) Unauthorized - Sharepoint
I got this error when accesing an xslt file. Here is the code. I get the above error at
"xsl.Load(xslURI) ". This is SP2013 and it is my vm box. I have administrative privelages. Looks like to me a security issue..
Protected Overrides Sub Render(ByVal writer As System.Web.UI.HtmlTextWrit er)
Dim xmldoc As XmlDocument = New XmlDocument()
Dim web As SPWeb = SPContext.Current.Web
Dim list As SPList = web.Lists("Test")
Dim li As SPListItem = list.GetItemById(CInt(Requ est.QueryS tring("ID" )))
xmldoc.LoadXml(li.Xml)
Dim xslURI As String = web.Url & "/SiteAssets/TestDisplay.x sl"
Dim xsl As XslCompiledTransform = New XslCompiledTransform()
xsl.Load(xslURI)
Dim sb As StringBuilder = New StringBuilder()
Dim sw As System.IO.StringWriter = New System.IO.StringWriter(sb)
Dim xmlw As XmlTextWriter = New XmlTextWriter(sw)
xsl.Transform(xmldoc, Nothing, xmlw)
Server.HtmlDecode(sb.ToStr ing.Replac e("~siteur l", web.ServerRelativeUrl), writer)
End Sub
End Class
"xsl.Load(xslURI) ". This is SP2013 and it is my vm box. I have administrative privelages. Looks like to me a security issue..
Protected Overrides Sub Render(ByVal writer As System.Web.UI.HtmlTextWrit
Dim xmldoc As XmlDocument = New XmlDocument()
Dim web As SPWeb = SPContext.Current.Web
Dim list As SPList = web.Lists("Test")
Dim li As SPListItem = list.GetItemById(CInt(Requ
xmldoc.LoadXml(li.Xml)
Dim xslURI As String = web.Url & "/SiteAssets/TestDisplay.x
Dim xsl As XslCompiledTransform = New XslCompiledTransform()
xsl.Load(xslURI)
Dim sb As StringBuilder = New StringBuilder()
Dim sw As System.IO.StringWriter = New System.IO.StringWriter(sb)
Dim xmlw As XmlTextWriter = New XmlTextWriter(sw)
xsl.Transform(xmldoc, Nothing, xmlw)
Server.HtmlDecode(sb.ToStr
End Sub
End Class
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Sorry for not back to you before now.
Is the file you are trying to access on the same server? If not you have to grant the access/permission for the account where the file is located.
Regards
Is the file you are trying to access on the same server? If not you have to grant the access/permission for the account where the file is located.
Regards
ASKER