Convert VB Script to C# script with MSXML2 request: Server.CreateObject("MSXML2.ServerXMLHTTP")

Hi,
I know C#, but not VB.  
How do I create the equivalent C# script for this VB Syntax?

Set xml Server.CreateObject("MSXML2.ServerXMLHTTP")

Thanks

complete function is here. but I can do the rest out, once I get the correct Objects set up.


<%
Function GetContent(url)
    Dim xmlHttp
    Set xml = Server.CreateObject("MSXML2.ServerXMLHTTP")
    xml.Open "GET", url, True
    Call xml.Send()

      If xml.readyState <> 4 Then
        xml.waitForResponse 3
    End If
   
     If Err.Number <> 0 Then
    Else
         If (xml.readyState <> 4) Or (xml.Status <> 200) Then
              xml.Abort
              strData = "Problem communicating with remote server..."
         Else
              strData = xml.ResponseText
         End If
    End If
    GetContent = strData
End Function
%>

<%=GetContent("http://oldlook.experts-exchange.com/")%>

paygoAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

fritz_the_blankCommented:
I may be very wrong about this as I don't know much about .Net yet and even less about C#, but is this what you need?

string postData = "";
string uriString = "http://www.FairfieldConsulting.com";
string strXML ;

XMLHTTPClass xmlHTTP = new XMLHTTPClass();

xmlHTTP.open("POST", uriString,false,null,null) ;
xmlHTTP.send(postData) ;

while(xmlHTTP.readyState != 4)
     {
     }
               
strXML = (string)xmlHTTP.responseText;
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
paygoAuthor Commented:
Thanks fritz this is correct.

But I get a MSXML4.dll  access denied error with some sites.

This is another post question I believe
0
fritz_the_blankCommented:
Thank you and best of luck. Don't forget, we have an ASP.Net area--you might have better luck finding your answer there.

FtB
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.