By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,833 Members | 2,076 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,833 IT Pros & Developers. It's quick & easy.

How do I perform an HTML POST from a button using vb.net code?

P: n/a
Hello,

I would like to do the following from a asp.net button click:

<form method="POST"
action="https://www.1234.com/trans_center/gateway/direct.cgi">
<input type="hidden" name="Merchant" value="Merchant Name">
<input type="hidden" name="OrderID" value="Unique OrderID value">
<input type="hidden" name="email" value="Customers email address
(OPTIONAL)">
<input type="hidden" name="total" value="total calculated transaction amount
value">
<input type="hidden" name="URL" value="http://Your Web Site Address/script
name to receive variables">

<input type="text" name="Cardname"><Br>
<input type="text" name="Cardnum1"><Br>
<input type="text" name="Cardnum2"><Br>
<input type="text" name="Cardnum3"><Br>
<input type="text" name="Cardnum4"><Br>
<input type="text" name="NameonCard"><Br>
<input type="text" name="Cardstreet"><Br>
<input type="text" name="Cardcity"><Br>
<input type="text" name="Cardstate"><Br>
<input type="text" name="Cardzip"><Br>
<input type="text" name="Cardcountry"><Br>
<input type="text" name="CardexpM"><Br>
<input type="text" name="CardexpY"><Br>
<input type="text" name="CVV2"><Br> </form>
I know that this can be done from inside the HTML but I would like to do
this same thing with VB.NET code inside a button click subroutine.

I am sure there is something inside the dot.net framework that allows this.
I just dont know what it is.

Thnaks for your help!

Justin
Nov 19 '05 #1
Share this Question
Share on Google+
7 Replies


P: n/a
using System.Net;
using System.IO;

request = (HttpWebRequest)WebRequest.Create(url);
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";
String data_to_post = "action=insert&first_name="+first_name+…;
byte[] bytes = System.Text.Encoding.UTF8.GetBytes(data_to_post);
request.ContentLength = bytes.Length;
request_stream = request.GetRequestStream();
request_stream.Write(bytes, 0, bytes.Length);
request_stream.Close();

//Read the server response
response = (HttpWebResponse)request.GetResponse();

"wa********@newsgroups.nospam" wrote:
Hello,

I would like to do the following from a asp.net button click:

<form method="POST"
action="https://www.1234.com/trans_center/gateway/direct.cgi">
<input type="hidden" name="Merchant" value="Merchant Name">
<input type="hidden" name="OrderID" value="Unique OrderID value">
<input type="hidden" name="email" value="Customers email address
(OPTIONAL)">
<input type="hidden" name="total" value="total calculated transaction amount
value">
<input type="hidden" name="URL" value="http://Your Web Site Address/script
name to receive variables">

<input type="text" name="Cardname"><Br>
<input type="text" name="Cardnum1"><Br>
<input type="text" name="Cardnum2"><Br>
<input type="text" name="Cardnum3"><Br>
<input type="text" name="Cardnum4"><Br>
<input type="text" name="NameonCard"><Br>
<input type="text" name="Cardstreet"><Br>
<input type="text" name="Cardcity"><Br>
<input type="text" name="Cardstate"><Br>
<input type="text" name="Cardzip"><Br>
<input type="text" name="Cardcountry"><Br>
<input type="text" name="CardexpM"><Br>
<input type="text" name="CardexpY"><Br>
<input type="text" name="CVV2"><Br> </form>
I know that this can be done from inside the HTML but I would like to do
this same thing with VB.NET code inside a button click subroutine.

I am sure there is something inside the dot.net framework that allows this.
I just dont know what it is.

Thnaks for your help!

Justin

Nov 19 '05 #2

P: n/a
Robert,

That works fine except that the response back is supposed to be in a query
string of a GET method. How would I read that from the response stream?

Here is the code that I wrote based on your post:

Dim webReq As HttpWebRequest =
CType(WebRequest.Create("https://www.goemerchant4.com/trans_center/gateway/direct.cgi"),
HttpWebRequest)

webReq.Method = "POST"

webReq.ContentType = "application/x-www-form-urlencoded"

Dim strInformation As String

strInformation = "Merchant=17778" & _

"&OrderID=1234567890" & _

"&total=100.98" & _

"&e**************@test.com" & _

"&URL=http://togs.washoetech.net/member_pages/order-form.aspx" & _

"&Cardname=Visa" & _

"&Cardnum1=1234" & _

"&Cardnum2=5678" & _

"&Cardnum3=9012" & _

"&Cardnum4=3456" & _

"&NameonCard=John Doe" & _

"&Cardstreet=1234 Happy Lane" & _

"&Cardcity=Reno" & _

"&Cardstate=Nevada" & _

"&Cardzip=89502" & _

"&Cardcountry=US" & _

"&CardexpM=09" & _

"&CardexpY=06" & _

"&CVV2=123" & _

"&e**************@test.com"

Dim bytes As Byte() = System.Text.Encoding.UTF8.GetBytes(strInformation)

webReq.ContentLength = bytes.Length

Dim requestStream As System.IO.Stream = webReq.GetRequestStream

requestStream.Write(bytes, 0, bytes.Length)

requestStream.Close()

Thanks

J

"Robert Burdick [eMVP]" <Ro***************@discussions.microsoft.com> wrote
in message news:0E**********************************@microsof t.com...
using System.Net;
using System.IO;

request = (HttpWebRequest)WebRequest.Create(url);
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";
String data_to_post = "action=insert&first_name="+first_name+.;
byte[] bytes = System.Text.Encoding.UTF8.GetBytes(data_to_post);
request.ContentLength = bytes.Length;
request_stream = request.GetRequestStream();
request_stream.Write(bytes, 0, bytes.Length);
request_stream.Close();

//Read the server response
response = (HttpWebResponse)request.GetResponse();
.
"wa********@newsgroups.nospam" wrote:
Hello,

I would like to do the following from a asp.net button click:

<form method="POST"
action="https://www.1234.com/trans_center/gateway/direct.cgi">
<input type="hidden" name="Merchant" value="Merchant Name">
<input type="hidden" name="OrderID" value="Unique OrderID value">
<input type="hidden" name="email" value="Customers email address
(OPTIONAL)">
<input type="hidden" name="total" value="total calculated transaction
amount
value">
<input type="hidden" name="URL" value="http://Your Web Site
Address/script
name to receive variables">

<input type="text" name="Cardname"><Br>
<input type="text" name="Cardnum1"><Br>
<input type="text" name="Cardnum2"><Br>
<input type="text" name="Cardnum3"><Br>
<input type="text" name="Cardnum4"><Br>
<input type="text" name="NameonCard"><Br>
<input type="text" name="Cardstreet"><Br>
<input type="text" name="Cardcity"><Br>
<input type="text" name="Cardstate"><Br>
<input type="text" name="Cardzip"><Br>
<input type="text" name="Cardcountry"><Br>
<input type="text" name="CardexpM"><Br>
<input type="text" name="CardexpY"><Br>
<input type="text" name="CVV2"><Br> </form>
I know that this can be done from inside the HTML but I would like to do
this same thing with VB.NET code inside a button click subroutine.

I am sure there is something inside the dot.net framework that allows
this.
I just dont know what it is.

Thnaks for your help!

Justin

Nov 19 '05 #3

P: n/a
Hi J,

After we call the HttpWebRequest.GetResponse() and the method return, we'll
get a HttpWebResponse object which contains the response data from the
serverside. And all the response data stream can be retrieve through the
HttpWebResponse.GetResponseStream() method, e.g:

HttpWebRequest request
............................

HttpWebResponse response = request.GetResponse() as HttpWebResponse;

System.IO.StreamReader reader = new
System.IO.StreamReader(response.GetResponseStream( ));

string reponseHTML = reader.ReadToEnd();

Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

--------------------
| Reply-To: <wa********@newsgroups.nospam>
| From: <wa********@newsgroups.nospam>
| References: <Os*************@TK2MSFTNGP10.phx.gbl>
<0E**********************************@microsoft.co m>
| Subject: Re: How do I perform an HTML POST from a button using vb.net
code?
| Date: Wed, 26 Oct 2005 17:22:48 -0700
| Lines: 141
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2900.2670
| X-RFC2646: Format=Flowed; Original
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2670
| Message-ID: <#S**************@TK2MSFTNGP10.phx.gbl>
| Newsgroups: microsoft.public.dotnet.framework.aspnet
| NNTP-Posting-Host: ip-206.159.118.137.hdiss.net 206.159.118.137
| Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFT NGP10.phx.gbl
| Xref: TK2MSFTNGXA01.phx.gbl
microsoft.public.dotnet.framework.aspnet:134157
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
|
| Robert,
|
| That works fine except that the response back is supposed to be in a
query
| string of a GET method. How would I read that from the response stream?
|
| Here is the code that I wrote based on your post:
|
| Dim webReq As HttpWebRequest =
|
CType(WebRequest.Create("https://www.goemerchant4.com/trans_center/gateway/d
irect.cgi"),
| HttpWebRequest)
|
| webReq.Method = "POST"
|
| webReq.ContentType = "application/x-www-form-urlencoded"
|
| Dim strInformation As String
|
| strInformation = "Merchant=17778" & _
|
| "&OrderID=1234567890" & _
|
| "&total=100.98" & _
|
| "&e**************@test.com" & _
|
| "&URL=http://togs.washoetech.net/member_pages/order-form.aspx" & _
|
| "&Cardname=Visa" & _
|
| "&Cardnum1=1234" & _
|
| "&Cardnum2=5678" & _
|
| "&Cardnum3=9012" & _
|
| "&Cardnum4=3456" & _
|
| "&NameonCard=John Doe" & _
|
| "&Cardstreet=1234 Happy Lane" & _
|
| "&Cardcity=Reno" & _
|
| "&Cardstate=Nevada" & _
|
| "&Cardzip=89502" & _
|
| "&Cardcountry=US" & _
|
| "&CardexpM=09" & _
|
| "&CardexpY=06" & _
|
| "&CVV2=123" & _
|
| "&e**************@test.com"
|
| Dim bytes As Byte() = System.Text.Encoding.UTF8.GetBytes(strInformation)
|
| webReq.ContentLength = bytes.Length
|
| Dim requestStream As System.IO.Stream = webReq.GetRequestStream
|
| requestStream.Write(bytes, 0, bytes.Length)
|
| requestStream.Close()
|
| Thanks
|
| J
|
| "Robert Burdick [eMVP]" <Ro***************@discussions.microsoft.com>
wrote
| in message news:0E**********************************@microsof t.com...
| > using System.Net;
| > using System.IO;
| >
| > request = (HttpWebRequest)WebRequest.Create(url);
| > request.Method = "POST";
| > request.ContentType = "application/x-www-form-urlencoded";
| > String data_to_post = "action=insert&first_name="+first_name+.;
| > byte[] bytes = System.Text.Encoding.UTF8.GetBytes(data_to_post);
| > request.ContentLength = bytes.Length;
| > request_stream = request.GetRequestStream();
| > request_stream.Write(bytes, 0, bytes.Length);
| > request_stream.Close();
| >
| > //Read the server response
| > response = (HttpWebResponse)request.GetResponse();
| > .
| >
| >
| > "wa********@newsgroups.nospam" wrote:
| >
| >> Hello,
| >>
| >> I would like to do the following from a asp.net button click:
| >>
| >> <form method="POST"
| >> action="https://www.1234.com/trans_center/gateway/direct.cgi">
| >> <input type="hidden" name="Merchant" value="Merchant Name">
| >> <input type="hidden" name="OrderID" value="Unique OrderID value">
| >> <input type="hidden" name="email" value="Customers email address
| >> (OPTIONAL)">
| >> <input type="hidden" name="total" value="total calculated transaction
| >> amount
| >> value">
| >> <input type="hidden" name="URL" value="http://Your Web Site
| >> Address/script
| >> name to receive variables">
| >>
| >> <input type="text" name="Cardname"><Br>
| >> <input type="text" name="Cardnum1"><Br>
| >> <input type="text" name="Cardnum2"><Br>
| >> <input type="text" name="Cardnum3"><Br>
| >> <input type="text" name="Cardnum4"><Br>
| >> <input type="text" name="NameonCard"><Br>
| >> <input type="text" name="Cardstreet"><Br>
| >> <input type="text" name="Cardcity"><Br>
| >> <input type="text" name="Cardstate"><Br>
| >> <input type="text" name="Cardzip"><Br>
| >> <input type="text" name="Cardcountry"><Br>
| >> <input type="text" name="CardexpM"><Br>
| >> <input type="text" name="CardexpY"><Br>
| >> <input type="text" name="CVV2"><Br> </form>
| >>
| >>
| >> I know that this can be done from inside the HTML but I would like to
do
| >> this same thing with VB.NET code inside a button click subroutine.
| >>
| >> I am sure there is something inside the dot.net framework that allows
| >> this.
| >> I just dont know what it is.
| >>
| >> Thnaks for your help!
| >>
| >> Justin
| >>
| >>
| >>
|
|
|

Nov 19 '05 #4

P: n/a
Steven,

I keep getting the following error:

"The server committed a protocol violation. Section=ResponseHeader Detail=CR
must be followed by LF"

I am using ASP.NET 2.0. Here is my code based on what you wrote:
'Receive Response

Dim webResponse As HttpWebResponse

webResponse = CType(webReq.GetResponse(), HttpWebResponse)

Dim rdrReader As System.IO.StreamReader

rdrReader = New System.IO.StreamReader(webResponse.GetResponseStre am)

Dim responseHTML As String

responseHTML = rdrReader.ReadToEnd

Label1.Text = responseHTML

I tried to do some searched on this error and I cant find any.
Thanks,

J

"Steven Cheng[MSFT]" <st*****@online.microsoft.com> wrote in message
news:hY****************@TK2MSFTNGXA01.phx.gbl...
Hi J,

After we call the HttpWebRequest.GetResponse() and the method return,
we'll
get a HttpWebResponse object which contains the response data from the
serverside. And all the response data stream can be retrieve through the
HttpWebResponse.GetResponseStream() method, e.g:

HttpWebRequest request
...........................

HttpWebResponse response = request.GetResponse() as HttpWebResponse;

System.IO.StreamReader reader = new
System.IO.StreamReader(response.GetResponseStream( ));

string reponseHTML = reader.ReadToEnd();

Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

--------------------
| Reply-To: <wa********@newsgroups.nospam>
| From: <wa********@newsgroups.nospam>
| References: <Os*************@TK2MSFTNGP10.phx.gbl>
<0E**********************************@microsoft.co m>
| Subject: Re: How do I perform an HTML POST from a button using vb.net
code?
| Date: Wed, 26 Oct 2005 17:22:48 -0700
| Lines: 141
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2900.2670
| X-RFC2646: Format=Flowed; Original
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2670
| Message-ID: <#S**************@TK2MSFTNGP10.phx.gbl>
| Newsgroups: microsoft.public.dotnet.framework.aspnet
| NNTP-Posting-Host: ip-206.159.118.137.hdiss.net 206.159.118.137
| Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFT NGP10.phx.gbl
| Xref: TK2MSFTNGXA01.phx.gbl
microsoft.public.dotnet.framework.aspnet:134157
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
|
| Robert,
|
| That works fine except that the response back is supposed to be in a
query
| string of a GET method. How would I read that from the response stream?
|
| Here is the code that I wrote based on your post:
|
| Dim webReq As HttpWebRequest =
|
CType(WebRequest.Create("https://www.goemerchant4.com/trans_center/gateway/d
irect.cgi"),
| HttpWebRequest)
|
| webReq.Method = "POST"
|
| webReq.ContentType = "application/x-www-form-urlencoded"
|
| Dim strInformation As String
|
| strInformation = "Merchant=17778" & _
|
| "&OrderID=1234567890" & _
|
| "&total=100.98" & _
|
| "&e**************@test.com" & _
|
| "&URL=http://togs.washoetech.net/member_pages/order-form.aspx" & _
|
| "&Cardname=Visa" & _
|
| "&Cardnum1=1234" & _
|
| "&Cardnum2=5678" & _
|
| "&Cardnum3=9012" & _
|
| "&Cardnum4=3456" & _
|
| "&NameonCard=John Doe" & _
|
| "&Cardstreet=1234 Happy Lane" & _
|
| "&Cardcity=Reno" & _
|
| "&Cardstate=Nevada" & _
|
| "&Cardzip=89502" & _
|
| "&Cardcountry=US" & _
|
| "&CardexpM=09" & _
|
| "&CardexpY=06" & _
|
| "&CVV2=123" & _
|
| "&e**************@test.com"
|
| Dim bytes As Byte() = System.Text.Encoding.UTF8.GetBytes(strInformation)
|
| webReq.ContentLength = bytes.Length
|
| Dim requestStream As System.IO.Stream = webReq.GetRequestStream
|
| requestStream.Write(bytes, 0, bytes.Length)
|
| requestStream.Close()
|
| Thanks
|
| J
|
| "Robert Burdick [eMVP]" <Ro***************@discussions.microsoft.com>
wrote
| in message news:0E**********************************@microsof t.com...
| > using System.Net;
| > using System.IO;
| >
| > request = (HttpWebRequest)WebRequest.Create(url);
| > request.Method = "POST";
| > request.ContentType = "application/x-www-form-urlencoded";
| > String data_to_post = "action=insert&first_name="+first_name+.;
| > byte[] bytes = System.Text.Encoding.UTF8.GetBytes(data_to_post);
| > request.ContentLength = bytes.Length;
| > request_stream = request.GetRequestStream();
| > request_stream.Write(bytes, 0, bytes.Length);
| > request_stream.Close();
| >
| > //Read the server response
| > response = (HttpWebResponse)request.GetResponse();
| > .
| >
| >
| > "wa********@newsgroups.nospam" wrote:
| >
| >> Hello,
| >>
| >> I would like to do the following from a asp.net button click:
| >>
| >> <form method="POST"
| >> action="https://www.1234.com/trans_center/gateway/direct.cgi">
| >> <input type="hidden" name="Merchant" value="Merchant Name">
| >> <input type="hidden" name="OrderID" value="Unique OrderID value">
| >> <input type="hidden" name="email" value="Customers email address
| >> (OPTIONAL)">
| >> <input type="hidden" name="total" value="total calculated transaction
| >> amount
| >> value">
| >> <input type="hidden" name="URL" value="http://Your Web Site
| >> Address/script
| >> name to receive variables">
| >>
| >> <input type="text" name="Cardname"><Br>
| >> <input type="text" name="Cardnum1"><Br>
| >> <input type="text" name="Cardnum2"><Br>
| >> <input type="text" name="Cardnum3"><Br>
| >> <input type="text" name="Cardnum4"><Br>
| >> <input type="text" name="NameonCard"><Br>
| >> <input type="text" name="Cardstreet"><Br>
| >> <input type="text" name="Cardcity"><Br>
| >> <input type="text" name="Cardstate"><Br>
| >> <input type="text" name="Cardzip"><Br>
| >> <input type="text" name="Cardcountry"><Br>
| >> <input type="text" name="CardexpM"><Br>
| >> <input type="text" name="CardexpY"><Br>
| >> <input type="text" name="CVV2"><Br> </form>
| >>
| >>
| >> I know that this can be done from inside the HTML but I would like to
do
| >> this same thing with VB.NET code inside a button click subroutine.
| >>
| >> I am sure there is something inside the dot.net framework that allows
| >> this.
| >> I just dont know what it is.
| >>
| >> Thnaks for your help!
| >>
| >> Justin
| >>
| >>
| >>
|
|
|

Nov 19 '05 #5

P: n/a
Hi J,

Thanks for your response.
I think this should be a page specific problems. Are you using the
httpwebRequest to programmatically request a ASP.NET 2.0 web page? If so,
you can try requesting another simple page 1.x or 2.0 instead to see
whether you encounter the same problem. If it is confirmed to be a page
specific one, we can try isolate the page and them simplify the page to
narrow down the problem.

Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

--------------------
| Reply-To: <wa********@newsgroups.nospam>
| From: <wa********@newsgroups.nospam>
| References: <Os*************@TK2MSFTNGP10.phx.gbl>
<0E**********************************@microsoft.co m>
<#S**************@TK2MSFTNGP10.phx.gbl>
<hY**************@TK2MSFTNGXA01.phx.gbl>
| Subject: Re: How do I perform an HTML POST from a button using vb.net
code?
| Date: Fri, 28 Oct 2005 09:58:32 -0700
| Lines: 234
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2900.2670
| X-RFC2646: Format=Flowed; Original
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2670
| Message-ID: <OF**************@TK2MSFTNGP12.phx.gbl>
| Newsgroups: microsoft.public.dotnet.framework.aspnet
| NNTP-Posting-Host: ip-206.159.118.137.hdiss.net 206.159.118.137
| Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFT NGP12.phx.gbl
| Xref: TK2MSFTNGXA01.phx.gbl
microsoft.public.dotnet.framework.aspnet:134571
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
|
| Steven,
|
| I keep getting the following error:
|
| "The server committed a protocol violation. Section=ResponseHeader
Detail=CR
| must be followed by LF"
|
| I am using ASP.NET 2.0. Here is my code based on what you wrote:
| 'Receive Response
|
| Dim webResponse As HttpWebResponse
|
| webResponse = CType(webReq.GetResponse(), HttpWebResponse)
|
| Dim rdrReader As System.IO.StreamReader
|
| rdrReader = New System.IO.StreamReader(webResponse.GetResponseStre am)
|
| Dim responseHTML As String
|
| responseHTML = rdrReader.ReadToEnd
|
| Label1.Text = responseHTML
|
| I tried to do some searched on this error and I cant find any.
|
|
| Thanks,
|
| J
|
| "Steven Cheng[MSFT]" <st*****@online.microsoft.com> wrote in message
| news:hY****************@TK2MSFTNGXA01.phx.gbl...
| > Hi J,
| >
| > After we call the HttpWebRequest.GetResponse() and the method return,
| > we'll
| > get a HttpWebResponse object which contains the response data from the
| > serverside. And all the response data stream can be retrieve through the
| > HttpWebResponse.GetResponseStream() method, e.g:
| >
| > HttpWebRequest request
| > ...........................
| >
| > HttpWebResponse response = request.GetResponse() as HttpWebResponse;
| >
| > System.IO.StreamReader reader = new
| > System.IO.StreamReader(response.GetResponseStream( ));
| >
| > string reponseHTML = reader.ReadToEnd();
| >
| > Thanks,
| >
| > Steven Cheng
| > Microsoft Online Support
| >
| > Get Secure! www.microsoft.com/security
| > (This posting is provided "AS IS", with no warranties, and confers no
| > rights.)
| >
| >
| >
| > --------------------
| > | Reply-To: <wa********@newsgroups.nospam>
| > | From: <wa********@newsgroups.nospam>
| > | References: <Os*************@TK2MSFTNGP10.phx.gbl>
| > <0E**********************************@microsoft.co m>
| > | Subject: Re: How do I perform an HTML POST from a button using vb.net
| > code?
| > | Date: Wed, 26 Oct 2005 17:22:48 -0700
| > | Lines: 141
| > | X-Priority: 3
| > | X-MSMail-Priority: Normal
| > | X-Newsreader: Microsoft Outlook Express 6.00.2900.2670
| > | X-RFC2646: Format=Flowed; Original
| > | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2670
| > | Message-ID: <#S**************@TK2MSFTNGP10.phx.gbl>
| > | Newsgroups: microsoft.public.dotnet.framework.aspnet
| > | NNTP-Posting-Host: ip-206.159.118.137.hdiss.net 206.159.118.137
| > | Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFT NGP10.phx.gbl
| > | Xref: TK2MSFTNGXA01.phx.gbl
| > microsoft.public.dotnet.framework.aspnet:134157
| > | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
| > |
| > | Robert,
| > |
| > | That works fine except that the response back is supposed to be in a
| > query
| > | string of a GET method. How would I read that from the response
stream?
| > |
| > | Here is the code that I wrote based on your post:
| > |
| > | Dim webReq As HttpWebRequest =
| > |
| >
CType(WebRequest.Create("https://www.goemerchant4.com/trans_center/gateway/d
| > irect.cgi"),
| > | HttpWebRequest)
| > |
| > | webReq.Method = "POST"
| > |
| > | webReq.ContentType = "application/x-www-form-urlencoded"
| > |
| > | Dim strInformation As String
| > |
| > | strInformation = "Merchant=17778" & _
| > |
| > | "&OrderID=1234567890" & _
| > |
| > | "&total=100.98" & _
| > |
| > | "&e**************@test.com" & _
| > |
| > | "&URL=http://togs.washoetech.net/member_pages/order-form.aspx" & _
| > |
| > | "&Cardname=Visa" & _
| > |
| > | "&Cardnum1=1234" & _
| > |
| > | "&Cardnum2=5678" & _
| > |
| > | "&Cardnum3=9012" & _
| > |
| > | "&Cardnum4=3456" & _
| > |
| > | "&NameonCard=John Doe" & _
| > |
| > | "&Cardstreet=1234 Happy Lane" & _
| > |
| > | "&Cardcity=Reno" & _
| > |
| > | "&Cardstate=Nevada" & _
| > |
| > | "&Cardzip=89502" & _
| > |
| > | "&Cardcountry=US" & _
| > |
| > | "&CardexpM=09" & _
| > |
| > | "&CardexpY=06" & _
| > |
| > | "&CVV2=123" & _
| > |
| > | "&e**************@test.com"
| > |
| > | Dim bytes As Byte() =
System.Text.Encoding.UTF8.GetBytes(strInformation)
| > |
| > | webReq.ContentLength = bytes.Length
| > |
| > | Dim requestStream As System.IO.Stream = webReq.GetRequestStream
| > |
| > | requestStream.Write(bytes, 0, bytes.Length)
| > |
| > | requestStream.Close()
| > |
| > | Thanks
| > |
| > | J
| > |
| > | "Robert Burdick [eMVP]" <Ro***************@discussions.microsoft.com>
| > wrote
| > | in message news:0E**********************************@microsof t.com...
| > | > using System.Net;
| > | > using System.IO;
| > | >
| > | > request = (HttpWebRequest)WebRequest.Create(url);
| > | > request.Method = "POST";
| > | > request.ContentType = "application/x-www-form-urlencoded";
| > | > String data_to_post = "action=insert&first_name="+first_name+.;
| > | > byte[] bytes = System.Text.Encoding.UTF8.GetBytes(data_to_post);
| > | > request.ContentLength = bytes.Length;
| > | > request_stream = request.GetRequestStream();
| > | > request_stream.Write(bytes, 0, bytes.Length);
| > | > request_stream.Close();
| > | >
| > | > //Read the server response
| > | > response = (HttpWebResponse)request.GetResponse();
| > | > .
| > | >
| > | >
| > | > "wa********@newsgroups.nospam" wrote:
| > | >
| > | >> Hello,
| > | >>
| > | >> I would like to do the following from a asp.net button click:
| > | >>
| > | >> <form method="POST"
| > | >> action="https://www.1234.com/trans_center/gateway/direct.cgi">
| > | >> <input type="hidden" name="Merchant" value="Merchant Name">
| > | >> <input type="hidden" name="OrderID" value="Unique OrderID value">
| > | >> <input type="hidden" name="email" value="Customers email address
| > | >> (OPTIONAL)">
| > | >> <input type="hidden" name="total" value="total calculated
transaction
| > | >> amount
| > | >> value">
| > | >> <input type="hidden" name="URL" value="http://Your Web Site
| > | >> Address/script
| > | >> name to receive variables">
| > | >>
| > | >> <input type="text" name="Cardname"><Br>
| > | >> <input type="text" name="Cardnum1"><Br>
| > | >> <input type="text" name="Cardnum2"><Br>
| > | >> <input type="text" name="Cardnum3"><Br>
| > | >> <input type="text" name="Cardnum4"><Br>
| > | >> <input type="text" name="NameonCard"><Br>
| > | >> <input type="text" name="Cardstreet"><Br>
| > | >> <input type="text" name="Cardcity"><Br>
| > | >> <input type="text" name="Cardstate"><Br>
| > | >> <input type="text" name="Cardzip"><Br>
| > | >> <input type="text" name="Cardcountry"><Br>
| > | >> <input type="text" name="CardexpM"><Br>
| > | >> <input type="text" name="CardexpY"><Br>
| > | >> <input type="text" name="CVV2"><Br> </form>
| > | >>
| > | >>
| > | >> I know that this can be done from inside the HTML but I would like
to
| > do
| > | >> this same thing with VB.NET code inside a button click subroutine.
| > | >>
| > | >> I am sure there is something inside the dot.net framework that
allows
| > | >> this.
| > | >> I just dont know what it is.
| > | >>
| > | >> Thnaks for your help!
| > | >>
| > | >> Justin
| > | >>
| > | >>
| > | >>
| > |
| > |
| > |
| >
|
|
|

Nov 19 '05 #6

P: n/a
Steven,

I was using the beta2 version of asp.net 2.0. I just installed the latest
release version. I am going to try and see if it happens again. I will let
you know.

Thanks,

j

"Steven Cheng[MSFT]" <st*****@online.microsoft.com> wrote in message
news:at**************@TK2MSFTNGXA01.phx.gbl...
Hi J,

Thanks for your response.
I think this should be a page specific problems. Are you using the
httpwebRequest to programmatically request a ASP.NET 2.0 web page? If so,
you can try requesting another simple page 1.x or 2.0 instead to see
whether you encounter the same problem. If it is confirmed to be a page
specific one, we can try isolate the page and them simplify the page to
narrow down the problem.

Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

--------------------
| Reply-To: <wa********@newsgroups.nospam>
| From: <wa********@newsgroups.nospam>
| References: <Os*************@TK2MSFTNGP10.phx.gbl>
<0E**********************************@microsoft.co m>
<#S**************@TK2MSFTNGP10.phx.gbl>
<hY**************@TK2MSFTNGXA01.phx.gbl>
| Subject: Re: How do I perform an HTML POST from a button using vb.net
code?
| Date: Fri, 28 Oct 2005 09:58:32 -0700
| Lines: 234
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2900.2670
| X-RFC2646: Format=Flowed; Original
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2670
| Message-ID: <OF**************@TK2MSFTNGP12.phx.gbl>
| Newsgroups: microsoft.public.dotnet.framework.aspnet
| NNTP-Posting-Host: ip-206.159.118.137.hdiss.net 206.159.118.137
| Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFT NGP12.phx.gbl
| Xref: TK2MSFTNGXA01.phx.gbl
microsoft.public.dotnet.framework.aspnet:134571
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
|
| Steven,
|
| I keep getting the following error:
|
| "The server committed a protocol violation. Section=ResponseHeader
Detail=CR
| must be followed by LF"
|
| I am using ASP.NET 2.0. Here is my code based on what you wrote:
| 'Receive Response
|
| Dim webResponse As HttpWebResponse
|
| webResponse = CType(webReq.GetResponse(), HttpWebResponse)
|
| Dim rdrReader As System.IO.StreamReader
|
| rdrReader = New System.IO.StreamReader(webResponse.GetResponseStre am)
|
| Dim responseHTML As String
|
| responseHTML = rdrReader.ReadToEnd
|
| Label1.Text = responseHTML
|
| I tried to do some searched on this error and I cant find any.
|
|
| Thanks,
|
| J
|
| "Steven Cheng[MSFT]" <st*****@online.microsoft.com> wrote in message
| news:hY****************@TK2MSFTNGXA01.phx.gbl...
| > Hi J,
| >
| > After we call the HttpWebRequest.GetResponse() and the method return,
| > we'll
| > get a HttpWebResponse object which contains the response data from the
| > serverside. And all the response data stream can be retrieve through
the
| > HttpWebResponse.GetResponseStream() method, e.g:
| >
| > HttpWebRequest request
| > ...........................
| >
| > HttpWebResponse response = request.GetResponse() as HttpWebResponse;
| >
| > System.IO.StreamReader reader = new
| > System.IO.StreamReader(response.GetResponseStream( ));
| >
| > string reponseHTML = reader.ReadToEnd();
| >
| > Thanks,
| >
| > Steven Cheng
| > Microsoft Online Support
| >
| > Get Secure! www.microsoft.com/security
| > (This posting is provided "AS IS", with no warranties, and confers no
| > rights.)
| >
| >
| >
| > --------------------
| > | Reply-To: <wa********@newsgroups.nospam>
| > | From: <wa********@newsgroups.nospam>
| > | References: <Os*************@TK2MSFTNGP10.phx.gbl>
| > <0E**********************************@microsoft.co m>
| > | Subject: Re: How do I perform an HTML POST from a button using
vb.net
| > code?
| > | Date: Wed, 26 Oct 2005 17:22:48 -0700
| > | Lines: 141
| > | X-Priority: 3
| > | X-MSMail-Priority: Normal
| > | X-Newsreader: Microsoft Outlook Express 6.00.2900.2670
| > | X-RFC2646: Format=Flowed; Original
| > | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2670
| > | Message-ID: <#S**************@TK2MSFTNGP10.phx.gbl>
| > | Newsgroups: microsoft.public.dotnet.framework.aspnet
| > | NNTP-Posting-Host: ip-206.159.118.137.hdiss.net 206.159.118.137
| > | Path:
TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFT NGP10.phx.gbl
| > | Xref: TK2MSFTNGXA01.phx.gbl
| > microsoft.public.dotnet.framework.aspnet:134157
| > | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
| > |
| > | Robert,
| > |
| > | That works fine except that the response back is supposed to be in a
| > query
| > | string of a GET method. How would I read that from the response
stream?
| > |
| > | Here is the code that I wrote based on your post:
| > |
| > | Dim webReq As HttpWebRequest =
| > |
| >
CType(WebRequest.Create("https://www.goemerchant4.com/trans_center/gateway/d
| > irect.cgi"),
| > | HttpWebRequest)
| > |
| > | webReq.Method = "POST"
| > |
| > | webReq.ContentType = "application/x-www-form-urlencoded"
| > |
| > | Dim strInformation As String
| > |
| > | strInformation = "Merchant=17778" & _
| > |
| > | "&OrderID=1234567890" & _
| > |
| > | "&total=100.98" & _
| > |
| > | "&e**************@test.com" & _
| > |
| > | "&URL=http://togs.washoetech.net/member_pages/order-form.aspx" & _
| > |
| > | "&Cardname=Visa" & _
| > |
| > | "&Cardnum1=1234" & _
| > |
| > | "&Cardnum2=5678" & _
| > |
| > | "&Cardnum3=9012" & _
| > |
| > | "&Cardnum4=3456" & _
| > |
| > | "&NameonCard=John Doe" & _
| > |
| > | "&Cardstreet=1234 Happy Lane" & _
| > |
| > | "&Cardcity=Reno" & _
| > |
| > | "&Cardstate=Nevada" & _
| > |
| > | "&Cardzip=89502" & _
| > |
| > | "&Cardcountry=US" & _
| > |
| > | "&CardexpM=09" & _
| > |
| > | "&CardexpY=06" & _
| > |
| > | "&CVV2=123" & _
| > |
| > | "&e**************@test.com"
| > |
| > | Dim bytes As Byte() =
System.Text.Encoding.UTF8.GetBytes(strInformation)
| > |
| > | webReq.ContentLength = bytes.Length
| > |
| > | Dim requestStream As System.IO.Stream = webReq.GetRequestStream
| > |
| > | requestStream.Write(bytes, 0, bytes.Length)
| > |
| > | requestStream.Close()
| > |
| > | Thanks
| > |
| > | J
| > |
| > | "Robert Burdick [eMVP]"
<Ro***************@discussions.microsoft.com>
| > wrote
| > | in message
news:0E**********************************@microsof t.com...
| > | > using System.Net;
| > | > using System.IO;
| > | >
| > | > request = (HttpWebRequest)WebRequest.Create(url);
| > | > request.Method = "POST";
| > | > request.ContentType = "application/x-www-form-urlencoded";
| > | > String data_to_post = "action=insert&first_name="+first_name+.;
| > | > byte[] bytes = System.Text.Encoding.UTF8.GetBytes(data_to_post);
| > | > request.ContentLength = bytes.Length;
| > | > request_stream = request.GetRequestStream();
| > | > request_stream.Write(bytes, 0, bytes.Length);
| > | > request_stream.Close();
| > | >
| > | > //Read the server response
| > | > response = (HttpWebResponse)request.GetResponse();
| > | > .
| > | >
| > | >
| > | > "wa********@newsgroups.nospam" wrote:
| > | >
| > | >> Hello,
| > | >>
| > | >> I would like to do the following from a asp.net button click:
| > | >>
| > | >> <form method="POST"
| > | >> action="https://www.1234.com/trans_center/gateway/direct.cgi">
| > | >> <input type="hidden" name="Merchant" value="Merchant Name">
| > | >> <input type="hidden" name="OrderID" value="Unique OrderID value">
| > | >> <input type="hidden" name="email" value="Customers email address
| > | >> (OPTIONAL)">
| > | >> <input type="hidden" name="total" value="total calculated
transaction
| > | >> amount
| > | >> value">
| > | >> <input type="hidden" name="URL" value="http://Your Web Site
| > | >> Address/script
| > | >> name to receive variables">
| > | >>
| > | >> <input type="text" name="Cardname"><Br>
| > | >> <input type="text" name="Cardnum1"><Br>
| > | >> <input type="text" name="Cardnum2"><Br>
| > | >> <input type="text" name="Cardnum3"><Br>
| > | >> <input type="text" name="Cardnum4"><Br>
| > | >> <input type="text" name="NameonCard"><Br>
| > | >> <input type="text" name="Cardstreet"><Br>
| > | >> <input type="text" name="Cardcity"><Br>
| > | >> <input type="text" name="Cardstate"><Br>
| > | >> <input type="text" name="Cardzip"><Br>
| > | >> <input type="text" name="Cardcountry"><Br>
| > | >> <input type="text" name="CardexpM"><Br>
| > | >> <input type="text" name="CardexpY"><Br>
| > | >> <input type="text" name="CVV2"><Br> </form>
| > | >>
| > | >>
| > | >> I know that this can be done from inside the HTML but I would
like
to
| > do
| > | >> this same thing with VB.NET code inside a button click
subroutine.
| > | >>
| > | >> I am sure there is something inside the dot.net framework that
allows
| > | >> this.
| > | >> I just dont know what it is.
| > | >>
| > | >> Thnaks for your help!
| > | >>
| > | >> Justin
| > | >>
| > | >>
| > | >>
| > |
| > |
| > |
| >
|
|
|

Nov 19 '05 #7

P: n/a
OK. Please feel free to let me know if you need any furhter assistance.

Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

--------------------
| Reply-To: <wa********@newsgroups.nospam>
| From: <wa********@newsgroups.nospam>
| References: <Os*************@TK2MSFTNGP10.phx.gbl>
<0E**********************************@microsoft.co m>
<#S**************@TK2MSFTNGP10.phx.gbl>
<hY**************@TK2MSFTNGXA01.phx.gbl>
<OF**************@TK2MSFTNGP12.phx.gbl>
<at**************@TK2MSFTNGXA01.phx.gbl>
| Subject: Re: How do I perform an HTML POST from a button using vb.net
code?
| Date: Tue, 1 Nov 2005 02:25:14 -0800
| Lines: 311
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2900.2670
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2670
| X-RFC2646: Format=Flowed; Original
| Message-ID: <ef**************@tk2msftngp13.phx.gbl>
| Newsgroups: microsoft.public.dotnet.framework.aspnet
| NNTP-Posting-Host: ip-206.159.118.137.hdiss.net 206.159.118.137
| Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msft ngp13.phx.gbl
| Xref: TK2MSFTNGXA01.phx.gbl
microsoft.public.dotnet.framework.aspnet:135171
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
|
| Steven,
|
| I was using the beta2 version of asp.net 2.0. I just installed the
latest
| release version. I am going to try and see if it happens again. I will
let
| you know.
|
| Thanks,
|
| j
|
| "Steven Cheng[MSFT]" <st*****@online.microsoft.com> wrote in message
| news:at**************@TK2MSFTNGXA01.phx.gbl...
| > Hi J,
| >
| > Thanks for your response.
| > I think this should be a page specific problems. Are you using the
| > httpwebRequest to programmatically request a ASP.NET 2.0 web page? If
so,
| > you can try requesting another simple page 1.x or 2.0 instead to see
| > whether you encounter the same problem. If it is confirmed to be a page
| > specific one, we can try isolate the page and them simplify the page to
| > narrow down the problem.
| >
| > Thanks,
| >
| > Steven Cheng
| > Microsoft Online Support
| >
| > Get Secure! www.microsoft.com/security
| > (This posting is provided "AS IS", with no warranties, and confers no
| > rights.)
| >
| >
| >
| >
| >
| > --------------------
| > | Reply-To: <wa********@newsgroups.nospam>
| > | From: <wa********@newsgroups.nospam>
| > | References: <Os*************@TK2MSFTNGP10.phx.gbl>
| > <0E**********************************@microsoft.co m>
| > <#S**************@TK2MSFTNGP10.phx.gbl>
| > <hY**************@TK2MSFTNGXA01.phx.gbl>
| > | Subject: Re: How do I perform an HTML POST from a button using vb.net
| > code?
| > | Date: Fri, 28 Oct 2005 09:58:32 -0700
| > | Lines: 234
| > | X-Priority: 3
| > | X-MSMail-Priority: Normal
| > | X-Newsreader: Microsoft Outlook Express 6.00.2900.2670
| > | X-RFC2646: Format=Flowed; Original
| > | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2670
| > | Message-ID: <OF**************@TK2MSFTNGP12.phx.gbl>
| > | Newsgroups: microsoft.public.dotnet.framework.aspnet
| > | NNTP-Posting-Host: ip-206.159.118.137.hdiss.net 206.159.118.137
| > | Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFT NGP12.phx.gbl
| > | Xref: TK2MSFTNGXA01.phx.gbl
| > microsoft.public.dotnet.framework.aspnet:134571
| > | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
| > |
| > | Steven,
| > |
| > | I keep getting the following error:
| > |
| > | "The server committed a protocol violation. Section=ResponseHeader
| > Detail=CR
| > | must be followed by LF"
| > |
| > | I am using ASP.NET 2.0. Here is my code based on what you wrote:
| > | 'Receive Response
| > |
| > | Dim webResponse As HttpWebResponse
| > |
| > | webResponse = CType(webReq.GetResponse(), HttpWebResponse)
| > |
| > | Dim rdrReader As System.IO.StreamReader
| > |
| > | rdrReader = New System.IO.StreamReader(webResponse.GetResponseStre am)
| > |
| > | Dim responseHTML As String
| > |
| > | responseHTML = rdrReader.ReadToEnd
| > |
| > | Label1.Text = responseHTML
| > |
| > | I tried to do some searched on this error and I cant find any.
| > |
| > |
| > | Thanks,
| > |
| > | J
| > |
| > | "Steven Cheng[MSFT]" <st*****@online.microsoft.com> wrote in message
| > | news:hY****************@TK2MSFTNGXA01.phx.gbl...
| > | > Hi J,
| > | >
| > | > After we call the HttpWebRequest.GetResponse() and the method
return,
| > | > we'll
| > | > get a HttpWebResponse object which contains the response data from
the
| > | > serverside. And all the response data stream can be retrieve
through
| > the
| > | > HttpWebResponse.GetResponseStream() method, e.g:
| > | >
| > | > HttpWebRequest request
| > | > ...........................
| > | >
| > | > HttpWebResponse response = request.GetResponse() as HttpWebResponse;
| > | >
| > | > System.IO.StreamReader reader = new
| > | > System.IO.StreamReader(response.GetResponseStream( ));
| > | >
| > | > string reponseHTML = reader.ReadToEnd();
| > | >
| > | > Thanks,
| > | >
| > | > Steven Cheng
| > | > Microsoft Online Support
| > | >
| > | > Get Secure! www.microsoft.com/security
| > | > (This posting is provided "AS IS", with no warranties, and confers
no
| > | > rights.)
| > | >
| > | >
| > | >
| > | > --------------------
| > | > | Reply-To: <wa********@newsgroups.nospam>
| > | > | From: <wa********@newsgroups.nospam>
| > | > | References: <Os*************@TK2MSFTNGP10.phx.gbl>
| > | > <0E**********************************@microsoft.co m>
| > | > | Subject: Re: How do I perform an HTML POST from a button using
| > vb.net
| > | > code?
| > | > | Date: Wed, 26 Oct 2005 17:22:48 -0700
| > | > | Lines: 141
| > | > | X-Priority: 3
| > | > | X-MSMail-Priority: Normal
| > | > | X-Newsreader: Microsoft Outlook Express 6.00.2900.2670
| > | > | X-RFC2646: Format=Flowed; Original
| > | > | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2670
| > | > | Message-ID: <#S**************@TK2MSFTNGP10.phx.gbl>
| > | > | Newsgroups: microsoft.public.dotnet.framework.aspnet
| > | > | NNTP-Posting-Host: ip-206.159.118.137.hdiss.net 206.159.118.137
| > | > | Path:
| > TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFT NGP10.phx.gbl
| > | > | Xref: TK2MSFTNGXA01.phx.gbl
| > | > microsoft.public.dotnet.framework.aspnet:134157
| > | > | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
| > | > |
| > | > | Robert,
| > | > |
| > | > | That works fine except that the response back is supposed to be
in a
| > | > query
| > | > | string of a GET method. How would I read that from the response
| > stream?
| > | > |
| > | > | Here is the code that I wrote based on your post:
| > | > |
| > | > | Dim webReq As HttpWebRequest =
| > | > |
| > | >
| >
CType(WebRequest.Create("https://www.goemerchant4.com/trans_center/gateway/d
| > | > irect.cgi"),
| > | > | HttpWebRequest)
| > | > |
| > | > | webReq.Method = "POST"
| > | > |
| > | > | webReq.ContentType = "application/x-www-form-urlencoded"
| > | > |
| > | > | Dim strInformation As String
| > | > |
| > | > | strInformation = "Merchant=17778" & _
| > | > |
| > | > | "&OrderID=1234567890" & _
| > | > |
| > | > | "&total=100.98" & _
| > | > |
| > | > | "&e**************@test.com" & _
| > | > |
| > | > | "&URL=http://togs.washoetech.net/member_pages/order-form.aspx" & _
| > | > |
| > | > | "&Cardname=Visa" & _
| > | > |
| > | > | "&Cardnum1=1234" & _
| > | > |
| > | > | "&Cardnum2=5678" & _
| > | > |
| > | > | "&Cardnum3=9012" & _
| > | > |
| > | > | "&Cardnum4=3456" & _
| > | > |
| > | > | "&NameonCard=John Doe" & _
| > | > |
| > | > | "&Cardstreet=1234 Happy Lane" & _
| > | > |
| > | > | "&Cardcity=Reno" & _
| > | > |
| > | > | "&Cardstate=Nevada" & _
| > | > |
| > | > | "&Cardzip=89502" & _
| > | > |
| > | > | "&Cardcountry=US" & _
| > | > |
| > | > | "&CardexpM=09" & _
| > | > |
| > | > | "&CardexpY=06" & _
| > | > |
| > | > | "&CVV2=123" & _
| > | > |
| > | > | "&e**************@test.com"
| > | > |
| > | > | Dim bytes As Byte() =
| > System.Text.Encoding.UTF8.GetBytes(strInformation)
| > | > |
| > | > | webReq.ContentLength = bytes.Length
| > | > |
| > | > | Dim requestStream As System.IO.Stream = webReq.GetRequestStream
| > | > |
| > | > | requestStream.Write(bytes, 0, bytes.Length)
| > | > |
| > | > | requestStream.Close()
| > | > |
| > | > | Thanks
| > | > |
| > | > | J
| > | > |
| > | > | "Robert Burdick [eMVP]"
| > <Ro***************@discussions.microsoft.com>
| > | > wrote
| > | > | in message
| > news:0E**********************************@microsof t.com...
| > | > | > using System.Net;
| > | > | > using System.IO;
| > | > | >
| > | > | > request = (HttpWebRequest)WebRequest.Create(url);
| > | > | > request.Method = "POST";
| > | > | > request.ContentType = "application/x-www-form-urlencoded";
| > | > | > String data_to_post = "action=insert&first_name="+first_name+.;
| > | > | > byte[] bytes = System.Text.Encoding.UTF8.GetBytes(data_to_post);
| > | > | > request.ContentLength = bytes.Length;
| > | > | > request_stream = request.GetRequestStream();
| > | > | > request_stream.Write(bytes, 0, bytes.Length);
| > | > | > request_stream.Close();
| > | > | >
| > | > | > //Read the server response
| > | > | > response = (HttpWebResponse)request.GetResponse();
| > | > | > .
| > | > | >
| > | > | >
| > | > | > "wa********@newsgroups.nospam" wrote:
| > | > | >
| > | > | >> Hello,
| > | > | >>
| > | > | >> I would like to do the following from a asp.net button click:
| > | > | >>
| > | > | >> <form method="POST"
| > | > | >> action="https://www.1234.com/trans_center/gateway/direct.cgi">
| > | > | >> <input type="hidden" name="Merchant" value="Merchant Name">
| > | > | >> <input type="hidden" name="OrderID" value="Unique OrderID
value">
| > | > | >> <input type="hidden" name="email" value="Customers email
address
| > | > | >> (OPTIONAL)">
| > | > | >> <input type="hidden" name="total" value="total calculated
| > transaction
| > | > | >> amount
| > | > | >> value">
| > | > | >> <input type="hidden" name="URL" value="http://Your Web Site
| > | > | >> Address/script
| > | > | >> name to receive variables">
| > | > | >>
| > | > | >> <input type="text" name="Cardname"><Br>
| > | > | >> <input type="text" name="Cardnum1"><Br>
| > | > | >> <input type="text" name="Cardnum2"><Br>
| > | > | >> <input type="text" name="Cardnum3"><Br>
| > | > | >> <input type="text" name="Cardnum4"><Br>
| > | > | >> <input type="text" name="NameonCard"><Br>
| > | > | >> <input type="text" name="Cardstreet"><Br>
| > | > | >> <input type="text" name="Cardcity"><Br>
| > | > | >> <input type="text" name="Cardstate"><Br>
| > | > | >> <input type="text" name="Cardzip"><Br>
| > | > | >> <input type="text" name="Cardcountry"><Br>
| > | > | >> <input type="text" name="CardexpM"><Br>
| > | > | >> <input type="text" name="CardexpY"><Br>
| > | > | >> <input type="text" name="CVV2"><Br> </form>
| > | > | >>
| > | > | >>
| > | > | >> I know that this can be done from inside the HTML but I would
| > like
| > to
| > | > do
| > | > | >> this same thing with VB.NET code inside a button click
| > subroutine.
| > | > | >>
| > | > | >> I am sure there is something inside the dot.net framework that
| > allows
| > | > | >> this.
| > | > | >> I just dont know what it is.
| > | > | >>
| > | > | >> Thnaks for your help!
| > | > | >>
| > | > | >> Justin
| > | > | >>
| > | > | >>
| > | > | >>
| > | > |
| > | > |
| > | > |
| > | >
| > |
| > |
| > |
| >
|
|
|

Nov 19 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.