tags:

views:

51

answers:

1

I am working on converting a VB6 app into C# app. Here what i need to do

Public Function SendData(sUsername as string ,sPassword as string, url as string , message as string ) As Boolean

Dim XMLHttpRequest   As MSXML2.XMLHTTP40
Set XMLHttpRequest = New MSXML2.XMLHTTP40

XMLHttpRequest.Open "GET", g_SonyFeedURL, True, sUsername, sPassword   
XMLHttpRequest.setRequestHeader "Synchronous", "False"
XMLHttpRequest.setRequestHeader "Content-Type", "text/xml"
XMLHttpRequest.setRequestHeader "Accept-Language", "en-US"
dtStart = Now
XMLHttpRequest.send
Do While XMLHttpRequest.ReadyState <> 4
            DoEvents            
            TimeOut = DateDiff("s", dtStart, Now)
            If TimeOut >= WaitTime Then 'Wait
              Exit Do
            End If
        Loop
End function

Now i understand i can do the above using httpwebrequest but not able to figure how to send the username and password or in other words what would be c# equivalent of

"XMLHttpRequest.Open "GET", g_SonyFeedURL, True, sUsername, sPassword "

and DoEvents so that i can make it wait for couple of min and if i dont get a reponse abort the request?

Any suggestions?

Thanks.

A: 

You might get away with using the WebClient class, although I haven't looked at it since the 1.1 days. It should be no different than the 'ajax' request made by XmlHttpRequest - after all, it's all GET/POST over HTTP.

kprobst