Solved

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

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

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 16

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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

This very simple solution applies to a narrow cross-section of the "needs to close" variety. In this case, the full message in Event Viewer was in applog, Event ID 1000: Faulting application iexplore.exe, version 8.0.6001.18702, faulting module …
These days socially coordinated efforts have turned into a critical requirement for enterprises.
The viewer will learn how to simulate a series of coin tosses with the rand() function and learn how to make these “tosses” depend on a predetermined probability. Flipping Coins in Excel: Enter =RAND() into cell A2: Recalculate the random variable…
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…

747 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

12 Experts available now in Live!

Get 1:1 Help Now