I am trying to retrieve XML data from an ASP page. If I type the URL to the
asp page into my browser (i.e. http://domain.com/getxml.asp) , I will get the
xml displayed in IE.
But, if I try to retrieve the xml using the xml web control, I get this error:
The remote server returned an error: (401) Unauthorized. Am I doing
something wrong? Below is the function that I created to read the xml:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Xml1.Document = GetXML("http://domain/getxml.asp")
End Sub
Function GetXML(ByVal strSourceFile As String)
Dim myRequest As System.Net.WebRequest =
System.Net.WebRequest.Create(strSourceFile)
Try
Dim myResponse As System.Net.WebResponse = myRequest.GetResponse()
Dim myReader As System.Xml.XmlTextReader = New
System.Xml.XmlTextReader(myResponse.GetResponseStr eam())
Dim doc As System.Xml.XmlDocument = New System.Xml.XmlDocument
doc.Load(myReader)
GetXML = doc
Catch
Response.Write(Err.Description)
End Try
End Function