DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 3 of 3
  1. #1
    jim Guest

    Can you simulate a form submission from ASP?


    Hi,

    Is it possible to do a server-side post (simulating a form submission) from
    ASP?

    I've heard that you can do this with the msmxml object, but I can't find
    any examples of a form post simulation on the web (at least not any that
    work!)

    Thanks.


  2. #2
    jim Guest

    Re: Can you simulate a form submission from ASP?


    Found the answer:

    <%
    dim oXML, url

    set oXML = Server.CreateObject("MSXML2.ServerXMLHTTP")

    url="http://www.somewebsite.com/login.cgi"

    oXML.Open "POST", url, false
    oXML.setRequestHeader "Content-Type","application/x-www-form-urlencoded"


    'We have to set this after the Open() method
    'A query string with a trailing space minus the leading question mark
    oXML.Send "txtUsername=dave&txtPassword=davespass&butLogin=enter "

    'You may want to just write the return data...
    'Response.write(oXML.responseText)

    %>
    <!-- ...but in this example I am redirecting to a particular page after the
    user is validated --->
    <body onload="location.replace('http://www.somewebsite.com/membersonlypage.htm')"></body>




    >
    >Hi,
    >
    >Is it possible to do a server-side post (simulating a form submission) from
    >ASP?
    >
    >I've heard that you can do this with the msmxml object, but I can't find
    >any examples of a form post simulation on the web (at least not any that
    >work!)
    >
    >Thanks.
    >



  3. #3
    jim Guest

    Re: Can you simulate a form submission from ASP?


    Oops - forgot to add:

    set oXML = nothing


    >
    >Found the answer:
    >
    ><%
    >dim oXML, url
    >
    >set oXML = Server.CreateObject("MSXML2.ServerXMLHTTP")
    >
    >url="http://www.somewebsite.com/login.cgi"
    >
    >oXML.Open "POST", url, false
    >oXML.setRequestHeader "Content-Type","application/x-www-form-urlencoded"
    >
    >
    >'We have to set this after the Open() method
    >'A query string with a trailing space minus the leading question mark
    >oXML.Send "txtUsername=dave&txtPassword=davespass&butLogin=enter "
    >
    >'You may want to just write the return data...
    >'Response.write(oXML.responseText)
    >
    >%>
    ><!-- ...but in this example I am redirecting to a particular page after

    the
    >user is validated --->
    ><body onload="location.replace('http://www.somewebsite.com/membersonlypage.htm')"></body>
    >
    >
    >
    >
    >>
    >>Hi,
    >>
    >>Is it possible to do a server-side post (simulating a form submission)

    from
    >>ASP?
    >>
    >>I've heard that you can do this with the msmxml object, but I can't find
    >>any examples of a form post simulation on the web (at least not any that
    >>work!)
    >>
    >>Thanks.
    >>

    >



Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links