Solved

WebException: The remote server returned an error: (401) Unauthorized - Sharepoint

Posted on 2013-11-04
3
1,058 Views
Last Modified: 2013-11-17
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
0
Comment
Question by:bujjigadu
  • 2
3 Comments
 
LVL 17

Accepted Solution

by:
Emmanuel Adebayo earned 300 total points
ID: 39623509
The account that is running your application pool need to have access to the .xlst file you are trying to access remotely.

Are you using default networking service account for your application pool? you might need to create an account specific for this.

Regards
0
 

Author Comment

by:bujjigadu
ID: 39624422
I'm using administrative account for the app settings. I changed it to use local system but still get the same error.
0
 
LVL 17

Expert Comment

by:Emmanuel Adebayo
ID: 39626645
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
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This collection of functions covers all the normal rounding methods of just about any numeric value.
Having trouble getting your hands on Dynamics 365 Field Service or Project Service trial? Worry No More!!!
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question