-
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.
-
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.
>
-
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.
>>
>
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
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
|
Bookmarks