Link to home
Start Free TrialLog in
Avatar of bujjigadu
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.HtmlTextWriter)
            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(Request.QueryString("ID")))
            xmldoc.LoadXml(li.Xml)
            Dim xslURI As String = web.Url & "/SiteAssets/TestDisplay.xsl"
            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.ToString.Replace("~siteurl", web.ServerRelativeUrl), writer)
        End Sub
    End Class
ASKER CERTIFIED SOLUTION
Avatar of Emmanuel Adebayo
Emmanuel Adebayo
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of bujjigadu
bujjigadu

ASKER

I'm using administrative account for the app settings. I changed it to use local system but still get the same error.
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