View Single Post
  #1 (permalink)  
Old July 16th, 2007, 06:40 AM
KamalRaturi KamalRaturi is offline
Authorized User
 
Join Date: Aug 2006
Location: delhi, delhi, India.
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to KamalRaturi Send a message via Yahoo to KamalRaturi
Default 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.