http post to another website

G

Guest

I am developing an application which will allow me to automatically sign into
an external website. I can currently do a screen scrape using
HTTPWEBREQUEST. However I want to just redirect to the external site. No
need to pull back any data.

Here is the code I am using.

Dim encoding As ASCIIEncoding = New ASCIIEncoding
Dim myParams As String = "AccessID=" & sUserID & "&Password=" &
sPassword
Dim data As Byte() = encoding.GetBytes(myParams)
Dim LOGIN_URL As String =
"https://www.blahblan.com/blah/blah.asp?WCE=RemoteLogon&IRL=T"

Dim WebRequest As HttpWebRequest =
CType(WebRequest.Create(LOGIN_URL), HttpWebRequest)
WebRequest.Method = "POST"
WebRequest.ContentLength = myParams.Length
WebRequest.ContentType = "application/x-www-form-urlencoded"

Dim myWriter As StreamWriter = New
StreamWriter(WebRequest.GetRequestStream())
myWriter.Write(myParams)
myWriter.Close()

At that point I would usually pull back the responsestream, but now I just
want to redirect to that website. I have tried appending the paramaters to
url to create a querystring, but that does not seem to work. I don't know
why as I don't have control over the external application.

Any thoughts?
Thanks
 
J

Joerg Jooss

Thus wrote Tyler,
I am developing an application which will allow me to automatically
sign into an external website. I can currently do a screen scrape
using HTTPWEBREQUEST. However I want to just redirect to the external
site. No need to pull back any data.

Here is the code I am using.

Dim encoding As ASCIIEncoding = New ASCIIEncoding
Dim myParams As String = "AccessID=" & sUserID & "&Password="
&
sPassword
Dim data As Byte() = encoding.GetBytes(myParams)
Dim LOGIN_URL As String =
"https://www.blahblan.com/blah/blah.asp?WCE=RemoteLogon&IRL=T"
Dim WebRequest As HttpWebRequest =
CType(WebRequest.Create(LOGIN_URL), HttpWebRequest)
WebRequest.Method = "POST"
WebRequest.ContentLength = myParams.Length
WebRequest.ContentType = "application/x-www-form-urlencoded"
Dim myWriter As StreamWriter = New
StreamWriter(WebRequest.GetRequestStream())
myWriter.Write(myParams)
myWriter.Close()
At that point I would usually pull back the responsestream, but now I
just want to redirect to that website. I have tried appending the
paramaters to url to create a querystring, but that does not seem to
work. I don't know why as I don't have control over the external
application.

I don't quite get what you're trying to achieve. A redirect is always issued
by the server side. On the client side, all you can do is follow the redirect
or remain stuck where you are.

Cheers,
 
G

Guest

Simply put, I am trying to logon to a website. I have a url, a username, and
a password. Normally I would put that data in a querystring like so
https://www.blahblan.com/blah/blah.asp?WCE=RemoteLogon&IRL=T&username=x;password=x

That will not work for some reason. I don't have any control over the
recieving website. However when I try a screen scrape as before (writing the
parameters to a streamwriter), I can login and pull back the html from that
site.

Instead of a screen scrape I want to simply send the user to the new
website.

With the data I have in hand, I would like to "redirect" the user to the new
website without using a querystring, but passing the variables along to
automatically login.

Am I making sense? If not please let me know and I will try and clarify
further.

Thanks for your help.
 
J

Joerg Jooss

Thus wrote Tyler,
Simply put, I am trying to logon to a website. I have a url, a
username, and a password. Normally I would put that data in a
querystring like so:
https://www.blahblan.com/blah/blah.asp?WCE=RemoteLogon&IRL=T&username=
x;password=x

You should never put sensitive data in a query string. This stuff should
be put in the HTTP message body. Even if you use HTTPS, the passwords might
show up in a server log at the destination site.
That will not work for some reason. I don't have any control over the
recieving website. However when I try a screen scrape as before
(writing the parameters to a streamwriter), I can login and pull back
the html from that site.

Writing parameters to the request stream performs a regular HTTP POST, and
it's what you should do in this case.
Instead of a screen scrape I want to simply send the user to the new
website.

Here's what still confuses me (or I've probably missed so far): What kind
of application are you developing? Are you trying to control another web
site from your web site, or are you trying to pull data from a web site that
lacks a more decent interface like a Web service?

Cheers,
 
G

Guest

I apologize. I know I am not making myself clear.

We have purchased a third party software. This third party software
requires you to logon to use the website. I am trying to integrate the
software into ours. In other words, they will already be signed into my
website. When I need to transfer to the 3rd party website, I want to be able
to do that seamlessly without the user knowing they are signing into a
"different" system. I can't do this with a querystring, and I don't want
to, but I need to be able to pass the current username and password to the
3rd party website to do an automatic signin. I can do this using
javascript, but I need to use VB.NET at this point. I hope that clarifies.

I appreciate your patience.
 
J

Joerg Jooss

Thus wrote Tyler,
I apologize. I know I am not making myself clear.

We have purchased a third party software. This third party software
requires you to logon to use the website. I am trying to integrate
the software into ours. In other words, they will already be signed
into my website. When I need to transfer to the 3rd party website, I
want to be able to do that seamlessly without the user knowing they
are signing into a "different" system. I can't do this with a
querystring, and I don't want to, but I need to be able to pass the
current username and password to the 3rd party website to do an
automatic signin. I can do this using javascript, but I need to use
VB.NET at this point. I hope that clarifies.

What about doing a POST to login, get the response and redirect the user
afterwards?

Or display the third party site in an IFRAME?

Cheers,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top