开发者

.net Equivalent of MSXML2.XMLHTTP40

I am working on converting a VB6 app i开发者_运维技巧nto 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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜