Basic authentication
Hi,
I'm trying to include some user credentials for accessing a remote
file (XML File).It can be accesed by dll'method at remote location . The remote location requires that I use Basic authentication. I tried using following code but when code execution comes at highlighted line it breaks itself and nothing happens.
CODE:
__________________________________________________ ______
Dim xmlDoc As XmlDocument = New XmlDocument
Dim request As HttpWebRequest = CType(WebRequest.Create("http://www.abc.ds/scripts/web.dll"), HttpWebRequest)
'Set Request Method (POST) and Content Type (text/xml)
request.Method = "POST"
request.ContentType = "text/xml"
request.ContentLength = 100000
request.Credentials = New System.Net.NetworkCredential("Username", "pwd")
request.Timeout = 15000
Dim str As Stream = Nothing
Dim resp As WebResponse = request.GetResponse() str = resp.GetResponseStream()
'Process Response
' Get Response into String
Dim sr As StreamReader = New StreamReader(str)
xmlDoc.LoadXml(sr.ReadToEnd())
'label1.text = xmlDoc.InnerXml
sr.Close()
str.Close()
__________________________________________
Can anyone help?
Thanks in Advance.
|