Solved

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

Posted on 2013-11-04
3
1,040 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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SharePoint Designer 2013 4 54
Convert a Master Page to HTML 16 85
Sharepoint KB 2 62
Authentication of Web Services 3 46
The System Center Operations Manager 2012, known as SCOM, is a part of the Microsoft system center product that provides the user with infrastructure monitoring and application performance monitoring. SCOM monitors:   Windows or UNIX/LinuxNetwo…
Technology opened people to different means of presenting information, but PowerPoint remains to be above competition. Know why PPT still works today.
Viewers will learn the different options available in the Backstage view in Excel 2013.
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

943 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now