How do I convert use of MSXML2.SERVERXMLHTTP from Classic ASP to C# in ASHX

For years we have been using the following vb code in a Classic ASP page to retrieve data from a software product.
To boost performance and get away from Classic ASP, I need to ASHX C# equivalent of the following  

    //set h = CreateObject("MSXML2.SERVERXMLHTTP")
    //h.open"POST", "http://localhost/isapi/webapi.dll"  //this is a software provided dll that accepts xml objects and returns xml response objects
    //h.setOption(2) = 4096
    //h.send(doc)
    //response.Write("<br><textarea rows=\"20\" cols=\"60\">" + h.responseText + "</textarea>");    
    //for each response in h.responseXml.selectnodes("//Response")
    //response.Write("<br><textarea rows=\"20\" cols=\"60\">" + response.xml + "</textarea>");
    //next
runner.txt
maxdbaseAsked:
Who is Participating?
 
Ryan ChongCommented:
〉〉To boost performance and get away from Classic ASP, I need to ASHX C# equivalent of the following  

you got to use .net class such as WebClient to send a web request.

there are also other similar ways to do that using other .net classes
0
 
Big MontySenior Web Developer / CEO of ExchangeTree.org Commented:
here's an example taken from here:

using System;
using MSXML2;  // Need to add a reference to C:\Windows\System32\msxml3.dll
 
namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Start");
 
            ServerXMLHTTP srv = new ServerXMLHTTP();
            srv.open("GET", @"http://www.hamiltonitblog.com", false,null,null);
            srv.send("");
 
            Console.WriteLine(srv.responseText);
 
            Console.ReadKey();
        }
    }
}

Open in new window

0
 
maxdbaseAuthor Commented:
I found and tried this before posting.
The ashx page tolerates the using MSXML2 but when I introduce  ServerXMLHTTP srv = new ServerXMLHTTP();
the page errs.  Screenshot of source  https://www.screencast.com/t/TFVovTqJ

This example is using GET.  My example uses POST and I believe that along with the other parameters are mandatory
for the software provided dll to consume this request.

Need more help specific to the example.

Thanks!
0
 
Big MontySenior Web Developer / CEO of ExchangeTree.org Commented:
the attached image doesnt show the error you're getting. Please copy and paste it here.
0
 
maxdbaseAuthor Commented:
<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head><title>

</title></head>
<body>
    <form method="post" action="./DefaultRedirectErrorPage.aspx?aspxerrorpath=%2fFinance%2fxml%2fstyle%2fcustom%2fsjsf%2fTOWEBFRM%2frunner%2frunner.ashx" id="form1">
<div class="aspNetHidden">
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="VgIBDmu9oT6Y/7u89GwgU8wHga8mHvyXH6yfTWXMquBaHJ7OivahUHGVMe/MG/qDQ+bqbC5zS69JgC0CwCTy2T3pk2rnyIZjNlM5bdPqHIm3Izs/" />
</div>

<div class="aspNetHidden">

      <input type="hidden" name="__VIEWSTATEGENERATOR" id="__VIEWSTATEGENERATOR" value="EAED47BF" />
      <input type="hidden" name="__VIEWSTATEENCRYPTED" id="__VIEWSTATEENCRYPTED" value="" />
</div>
    <div>
   
    </div>
    </form>
</body>
</html>
0
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.

All Courses

From novice to tech pro — start learning today.