473,769 Members | 1,917 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

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="Customer s 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="NameonCar d"><Br>
<input type="text" name="Cardstree t"><Br>
<input type="text" name="Cardcity" ><Br>
<input type="text" name="Cardstate "><Br>
<input type="text" name="Cardzip"> <Br>
<input type="text" name="Cardcount ry"><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
7 4263
using System.Net;
using System.IO;

request = (HttpWebRequest )WebRequest.Cre ate(url);
request.Method = "POST";
request.Content Type = "applicatio n/x-www-form-urlencoded";
String data_to_post = "action=insert& first_name="+fi rst_name+…;
byte[] bytes = System.Text.Enc oding.UTF8.GetB ytes(data_to_po st);
request.Content Length = bytes.Length;
request_stream = request.GetRequ estStream();
request_stream. Write(bytes, 0, bytes.Length);
request_stream. Close();

//Read the server response
response = (HttpWebRespons e)request.GetRe sponse();
…
"wa********@new sgroups.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="Customer s 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="NameonCar d"><Br>
<input type="text" name="Cardstree t"><Br>
<input type="text" name="Cardcity" ><Br>
<input type="text" name="Cardstate "><Br>
<input type="text" name="Cardzip"> <Br>
<input type="text" name="Cardcount ry"><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
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(WebReques t.Create("https ://www.goemerchant 4.com/trans_center/gateway/direct.cgi"),
HttpWebRequest)

webReq.Method = "POST"

webReq.ContentT ype = "applicatio n/x-www-form-urlencoded"

Dim strInformation As String

strInformation = "Merchant=17778 " & _

"&OrderID=12345 67890" & _

"&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=Jo hn Doe" & _

"&Cardstreet=12 34 Happy Lane" & _

"&Cardcity=Reno " & _

"&Cardstate=Nev ada" & _

"&Cardzip=89502 " & _

"&Cardcountry=U S" & _

"&CardexpM= 09" & _

"&CardexpY= 06" & _

"&CVV2=123" & _

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

Dim bytes As Byte() = System.Text.Enc oding.UTF8.GetB ytes(strInforma tion)

webReq.ContentL ength = bytes.Length

Dim requestStream As System.IO.Strea m = webReq.GetReque stStream

requestStream.W rite(bytes, 0, bytes.Length)

requestStream.C lose()

Thanks

J

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

request = (HttpWebRequest )WebRequest.Cre ate(url);
request.Method = "POST";
request.Content Type = "applicatio n/x-www-form-urlencoded";
String data_to_post = "action=insert& first_name="+fi rst_name+.;
byte[] bytes = System.Text.Enc oding.UTF8.GetB ytes(data_to_po st);
request.Content Length = bytes.Length;
request_stream = request.GetRequ estStream();
request_stream. Write(bytes, 0, bytes.Length);
request_stream. Close();

//Read the server response
response = (HttpWebRespons e)request.GetRe sponse();
.
"wa********@new sgroups.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="Customer s 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="NameonCar d"><Br>
<input type="text" name="Cardstree t"><Br>
<input type="text" name="Cardcity" ><Br>
<input type="text" name="Cardstate "><Br>
<input type="text" name="Cardzip"> <Br>
<input type="text" name="Cardcount ry"><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
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 .GetResponseStr eam() method, e.g:

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

HttpWebResponse response = request.GetResp onse() as HttpWebResponse ;

System.IO.Strea mReader reader = new
System.IO.Strea mReader(respons e.GetResponseSt ream());

string reponseHTML = reader.ReadToEn d();

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********@new sgroups.nospam>
| From: <wa********@new sgroups.nospam>
| References: <Os************ *@TK2MSFTNGP10. phx.gbl>
<0E************ *************** *******@microso ft.com>
| 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.publi c.dotnet.framew ork.aspnet
| NNTP-Posting-Host: ip-206.159.118.137 .hdiss.net 206.159.118.137
| Path: TK2MSFTNGXA01.p hx.gbl!TK2MSFTN GP08.phx.gbl!TK 2MSFTNGP10.phx. gbl
| Xref: TK2MSFTNGXA01.p hx.gbl
microsoft.publi c.dotnet.framew ork.aspnet:1341 57
| X-Tomcat-NG: microsoft.publi c.dotnet.framew ork.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(WebReques t.Create("https ://www.goemerchant 4.com/trans_center/gateway/d
irect.cgi"),
| HttpWebRequest)
|
| webReq.Method = "POST"
|
| webReq.ContentT ype = "applicatio n/x-www-form-urlencoded"
|
| Dim strInformation As String
|
| strInformation = "Merchant=17778 " & _
|
| "&OrderID=12345 67890" & _
|
| "&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=Jo hn Doe" & _
|
| "&Cardstreet=12 34 Happy Lane" & _
|
| "&Cardcity=Reno " & _
|
| "&Cardstate=Nev ada" & _
|
| "&Cardzip=89502 " & _
|
| "&Cardcountry=U S" & _
|
| "&CardexpM= 09" & _
|
| "&CardexpY= 06" & _
|
| "&CVV2=123" & _
|
| "&e************ **@test.com"
|
| Dim bytes As Byte() = System.Text.Enc oding.UTF8.GetB ytes(strInforma tion)
|
| webReq.ContentL ength = bytes.Length
|
| Dim requestStream As System.IO.Strea m = webReq.GetReque stStream
|
| requestStream.W rite(bytes, 0, bytes.Length)
|
| requestStream.C lose()
|
| Thanks
|
| J
|
| "Robert Burdick [eMVP]" <Ro************ ***@discussions .microsoft.com>
wrote
| in message news:0E******** *************** ***********@mic rosoft.com...
| > using System.Net;
| > using System.IO;
| >
| > request = (HttpWebRequest )WebRequest.Cre ate(url);
| > request.Method = "POST";
| > request.Content Type = "applicatio n/x-www-form-urlencoded";
| > String data_to_post = "action=insert& first_name="+fi rst_name+.;
| > byte[] bytes = System.Text.Enc oding.UTF8.GetB ytes(data_to_po st);
| > request.Content Length = bytes.Length;
| > request_stream = request.GetRequ estStream();
| > request_stream. Write(bytes, 0, bytes.Length);
| > request_stream. Close();
| >
| > //Read the server response
| > response = (HttpWebRespons e)request.GetRe sponse();
| > .
| >
| >
| > "wa********@new sgroups.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="Customer s 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="NameonCar d"><Br>
| >> <input type="text" name="Cardstree t"><Br>
| >> <input type="text" name="Cardcity" ><Br>
| >> <input type="text" name="Cardstate "><Br>
| >> <input type="text" name="Cardzip"> <Br>
| >> <input type="text" name="Cardcount ry"><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
Steven,

I keep getting the following error:

"The server committed a protocol violation. Section=Respons eHeader 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.Ge tResponse(), HttpWebResponse )

Dim rdrReader As System.IO.Strea mReader

rdrReader = New System.IO.Strea mReader(webResp onse.GetRespons eStream)

Dim responseHTML As String

responseHTML = rdrReader.ReadT oEnd

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******** ********@TK2MSF TNGXA01.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 .GetResponseStr eam() method, e.g:

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

HttpWebResponse response = request.GetResp onse() as HttpWebResponse ;

System.IO.Strea mReader reader = new
System.IO.Strea mReader(respons e.GetResponseSt ream());

string reponseHTML = reader.ReadToEn d();

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********@new sgroups.nospam>
| From: <wa********@new sgroups.nospam>
| References: <Os************ *@TK2MSFTNGP10. phx.gbl>
<0E************ *************** *******@microso ft.com>
| 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.publi c.dotnet.framew ork.aspnet
| NNTP-Posting-Host: ip-206.159.118.137 .hdiss.net 206.159.118.137
| Path: TK2MSFTNGXA01.p hx.gbl!TK2MSFTN GP08.phx.gbl!TK 2MSFTNGP10.phx. gbl
| Xref: TK2MSFTNGXA01.p hx.gbl
microsoft.publi c.dotnet.framew ork.aspnet:1341 57
| X-Tomcat-NG: microsoft.publi c.dotnet.framew ork.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(WebReques t.Create("https ://www.goemerchant 4.com/trans_center/gateway/d
irect.cgi"),
| HttpWebRequest)
|
| webReq.Method = "POST"
|
| webReq.ContentT ype = "applicatio n/x-www-form-urlencoded"
|
| Dim strInformation As String
|
| strInformation = "Merchant=17778 " & _
|
| "&OrderID=12345 67890" & _
|
| "&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=Jo hn Doe" & _
|
| "&Cardstreet=12 34 Happy Lane" & _
|
| "&Cardcity=Reno " & _
|
| "&Cardstate=Nev ada" & _
|
| "&Cardzip=89502 " & _
|
| "&Cardcountry=U S" & _
|
| "&CardexpM= 09" & _
|
| "&CardexpY= 06" & _
|
| "&CVV2=123" & _
|
| "&e************ **@test.com"
|
| Dim bytes As Byte() = System.Text.Enc oding.UTF8.GetB ytes(strInforma tion)
|
| webReq.ContentL ength = bytes.Length
|
| Dim requestStream As System.IO.Strea m = webReq.GetReque stStream
|
| requestStream.W rite(bytes, 0, bytes.Length)
|
| requestStream.C lose()
|
| Thanks
|
| J
|
| "Robert Burdick [eMVP]" <Ro************ ***@discussions .microsoft.com>
wrote
| in message news:0E******** *************** ***********@mic rosoft.com...
| > using System.Net;
| > using System.IO;
| >
| > request = (HttpWebRequest )WebRequest.Cre ate(url);
| > request.Method = "POST";
| > request.Content Type = "applicatio n/x-www-form-urlencoded";
| > String data_to_post = "action=insert& first_name="+fi rst_name+.;
| > byte[] bytes = System.Text.Enc oding.UTF8.GetB ytes(data_to_po st);
| > request.Content Length = bytes.Length;
| > request_stream = request.GetRequ estStream();
| > request_stream. Write(bytes, 0, bytes.Length);
| > request_stream. Close();
| >
| > //Read the server response
| > response = (HttpWebRespons e)request.GetRe sponse();
| > .
| >
| >
| > "wa********@new sgroups.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="Customer s 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="NameonCar d"><Br>
| >> <input type="text" name="Cardstree t"><Br>
| >> <input type="text" name="Cardcity" ><Br>
| >> <input type="text" name="Cardstate "><Br>
| >> <input type="text" name="Cardzip"> <Br>
| >> <input type="text" name="Cardcount ry"><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
Hi J,

Thanks for your response.
I think this should be a page specific problems. Are you using the
httpwebRequest to programmaticall y 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********@new sgroups.nospam>
| From: <wa********@new sgroups.nospam>
| References: <Os************ *@TK2MSFTNGP10. phx.gbl>
<0E************ *************** *******@microso ft.com>
<#S************ **@TK2MSFTNGP10 .phx.gbl>
<hY************ **@TK2MSFTNGXA0 1.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.publi c.dotnet.framew ork.aspnet
| NNTP-Posting-Host: ip-206.159.118.137 .hdiss.net 206.159.118.137
| Path: TK2MSFTNGXA01.p hx.gbl!TK2MSFTN GP08.phx.gbl!TK 2MSFTNGP12.phx. gbl
| Xref: TK2MSFTNGXA01.p hx.gbl
microsoft.publi c.dotnet.framew ork.aspnet:1345 71
| X-Tomcat-NG: microsoft.publi c.dotnet.framew ork.aspnet
|
| Steven,
|
| I keep getting the following error:
|
| "The server committed a protocol violation. Section=Respons eHeader
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.Ge tResponse(), HttpWebResponse )
|
| Dim rdrReader As System.IO.Strea mReader
|
| rdrReader = New System.IO.Strea mReader(webResp onse.GetRespons eStream)
|
| Dim responseHTML As String
|
| responseHTML = rdrReader.ReadT oEnd
|
| 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******** ********@TK2MSF TNGXA01.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 .GetResponseStr eam() method, e.g:
| >
| > HttpWebRequest request
| > ............... ............
| >
| > HttpWebResponse response = request.GetResp onse() as HttpWebResponse ;
| >
| > System.IO.Strea mReader reader = new
| > System.IO.Strea mReader(respons e.GetResponseSt ream());
| >
| > string reponseHTML = reader.ReadToEn d();
| >
| > 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********@new sgroups.nospam>
| > | From: <wa********@new sgroups.nospam>
| > | References: <Os************ *@TK2MSFTNGP10. phx.gbl>
| > <0E************ *************** *******@microso ft.com>
| > | 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.publi c.dotnet.framew ork.aspnet
| > | NNTP-Posting-Host: ip-206.159.118.137 .hdiss.net 206.159.118.137
| > | Path: TK2MSFTNGXA01.p hx.gbl!TK2MSFTN GP08.phx.gbl!TK 2MSFTNGP10.phx. gbl
| > | Xref: TK2MSFTNGXA01.p hx.gbl
| > microsoft.publi c.dotnet.framew ork.aspnet:1341 57
| > | X-Tomcat-NG: microsoft.publi c.dotnet.framew ork.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(WebReques t.Create("https ://www.goemerchant 4.com/trans_center/gateway/d
| > irect.cgi"),
| > | HttpWebRequest)
| > |
| > | webReq.Method = "POST"
| > |
| > | webReq.ContentT ype = "applicatio n/x-www-form-urlencoded"
| > |
| > | Dim strInformation As String
| > |
| > | strInformation = "Merchant=17778 " & _
| > |
| > | "&OrderID=12345 67890" & _
| > |
| > | "&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=Jo hn Doe" & _
| > |
| > | "&Cardstreet=12 34 Happy Lane" & _
| > |
| > | "&Cardcity=Reno " & _
| > |
| > | "&Cardstate=Nev ada" & _
| > |
| > | "&Cardzip=89502 " & _
| > |
| > | "&Cardcountry=U S" & _
| > |
| > | "&CardexpM= 09" & _
| > |
| > | "&CardexpY= 06" & _
| > |
| > | "&CVV2=123" & _
| > |
| > | "&e************ **@test.com"
| > |
| > | Dim bytes As Byte() =
System.Text.Enc oding.UTF8.GetB ytes(strInforma tion)
| > |
| > | webReq.ContentL ength = bytes.Length
| > |
| > | Dim requestStream As System.IO.Strea m = webReq.GetReque stStream
| > |
| > | requestStream.W rite(bytes, 0, bytes.Length)
| > |
| > | requestStream.C lose()
| > |
| > | Thanks
| > |
| > | J
| > |
| > | "Robert Burdick [eMVP]" <Ro************ ***@discussions .microsoft.com>
| > wrote
| > | in message news:0E******** *************** ***********@mic rosoft.com...
| > | > using System.Net;
| > | > using System.IO;
| > | >
| > | > request = (HttpWebRequest )WebRequest.Cre ate(url);
| > | > request.Method = "POST";
| > | > request.Content Type = "applicatio n/x-www-form-urlencoded";
| > | > String data_to_post = "action=insert& first_name="+fi rst_name+.;
| > | > byte[] bytes = System.Text.Enc oding.UTF8.GetB ytes(data_to_po st);
| > | > request.Content Length = bytes.Length;
| > | > request_stream = request.GetRequ estStream();
| > | > request_stream. Write(bytes, 0, bytes.Length);
| > | > request_stream. Close();
| > | >
| > | > //Read the server response
| > | > response = (HttpWebRespons e)request.GetRe sponse();
| > | > .
| > | >
| > | >
| > | > "wa********@new sgroups.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="Customer s 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="NameonCar d"><Br>
| > | >> <input type="text" name="Cardstree t"><Br>
| > | >> <input type="text" name="Cardcity" ><Br>
| > | >> <input type="text" name="Cardstate "><Br>
| > | >> <input type="text" name="Cardzip"> <Br>
| > | >> <input type="text" name="Cardcount ry"><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
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******** ******@TK2MSFTN GXA01.phx.gbl.. .
Hi J,

Thanks for your response.
I think this should be a page specific problems. Are you using the
httpwebRequest to programmaticall y 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********@new sgroups.nospam>
| From: <wa********@new sgroups.nospam>
| References: <Os************ *@TK2MSFTNGP10. phx.gbl>
<0E************ *************** *******@microso ft.com>
<#S************ **@TK2MSFTNGP10 .phx.gbl>
<hY************ **@TK2MSFTNGXA0 1.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.publi c.dotnet.framew ork.aspnet
| NNTP-Posting-Host: ip-206.159.118.137 .hdiss.net 206.159.118.137
| Path: TK2MSFTNGXA01.p hx.gbl!TK2MSFTN GP08.phx.gbl!TK 2MSFTNGP12.phx. gbl
| Xref: TK2MSFTNGXA01.p hx.gbl
microsoft.publi c.dotnet.framew ork.aspnet:1345 71
| X-Tomcat-NG: microsoft.publi c.dotnet.framew ork.aspnet
|
| Steven,
|
| I keep getting the following error:
|
| "The server committed a protocol violation. Section=Respons eHeader
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.Ge tResponse(), HttpWebResponse )
|
| Dim rdrReader As System.IO.Strea mReader
|
| rdrReader = New System.IO.Strea mReader(webResp onse.GetRespons eStream)
|
| Dim responseHTML As String
|
| responseHTML = rdrReader.ReadT oEnd
|
| 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******** ********@TK2MSF TNGXA01.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 .GetResponseStr eam() method, e.g:
| >
| > HttpWebRequest request
| > ............... ............
| >
| > HttpWebResponse response = request.GetResp onse() as HttpWebResponse ;
| >
| > System.IO.Strea mReader reader = new
| > System.IO.Strea mReader(respons e.GetResponseSt ream());
| >
| > string reponseHTML = reader.ReadToEn d();
| >
| > 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********@new sgroups.nospam>
| > | From: <wa********@new sgroups.nospam>
| > | References: <Os************ *@TK2MSFTNGP10. phx.gbl>
| > <0E************ *************** *******@microso ft.com>
| > | 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.publi c.dotnet.framew ork.aspnet
| > | NNTP-Posting-Host: ip-206.159.118.137 .hdiss.net 206.159.118.137
| > | Path:
TK2MSFTNGXA01.p hx.gbl!TK2MSFTN GP08.phx.gbl!TK 2MSFTNGP10.phx. gbl
| > | Xref: TK2MSFTNGXA01.p hx.gbl
| > microsoft.publi c.dotnet.framew ork.aspnet:1341 57
| > | X-Tomcat-NG: microsoft.publi c.dotnet.framew ork.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(WebReques t.Create("https ://www.goemerchant 4.com/trans_center/gateway/d
| > irect.cgi"),
| > | HttpWebRequest)
| > |
| > | webReq.Method = "POST"
| > |
| > | webReq.ContentT ype = "applicatio n/x-www-form-urlencoded"
| > |
| > | Dim strInformation As String
| > |
| > | strInformation = "Merchant=17778 " & _
| > |
| > | "&OrderID=12345 67890" & _
| > |
| > | "&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=Jo hn Doe" & _
| > |
| > | "&Cardstreet=12 34 Happy Lane" & _
| > |
| > | "&Cardcity=Reno " & _
| > |
| > | "&Cardstate=Nev ada" & _
| > |
| > | "&Cardzip=89502 " & _
| > |
| > | "&Cardcountry=U S" & _
| > |
| > | "&CardexpM= 09" & _
| > |
| > | "&CardexpY= 06" & _
| > |
| > | "&CVV2=123" & _
| > |
| > | "&e************ **@test.com"
| > |
| > | Dim bytes As Byte() =
System.Text.Enc oding.UTF8.GetB ytes(strInforma tion)
| > |
| > | webReq.ContentL ength = bytes.Length
| > |
| > | Dim requestStream As System.IO.Strea m = webReq.GetReque stStream
| > |
| > | requestStream.W rite(bytes, 0, bytes.Length)
| > |
| > | requestStream.C lose()
| > |
| > | Thanks
| > |
| > | J
| > |
| > | "Robert Burdick [eMVP]"
<Ro************ ***@discussions .microsoft.com>
| > wrote
| > | in message
news:0E******** *************** ***********@mic rosoft.com...
| > | > using System.Net;
| > | > using System.IO;
| > | >
| > | > request = (HttpWebRequest )WebRequest.Cre ate(url);
| > | > request.Method = "POST";
| > | > request.Content Type = "applicatio n/x-www-form-urlencoded";
| > | > String data_to_post = "action=insert& first_name="+fi rst_name+.;
| > | > byte[] bytes = System.Text.Enc oding.UTF8.GetB ytes(data_to_po st);
| > | > request.Content Length = bytes.Length;
| > | > request_stream = request.GetRequ estStream();
| > | > request_stream. Write(bytes, 0, bytes.Length);
| > | > request_stream. Close();
| > | >
| > | > //Read the server response
| > | > response = (HttpWebRespons e)request.GetRe sponse();
| > | > .
| > | >
| > | >
| > | > "wa********@new sgroups.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="Customer s 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="NameonCar d"><Br>
| > | >> <input type="text" name="Cardstree t"><Br>
| > | >> <input type="text" name="Cardcity" ><Br>
| > | >> <input type="text" name="Cardstate "><Br>
| > | >> <input type="text" name="Cardzip"> <Br>
| > | >> <input type="text" name="Cardcount ry"><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
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********@new sgroups.nospam>
| From: <wa********@new sgroups.nospam>
| References: <Os************ *@TK2MSFTNGP10. phx.gbl>
<0E************ *************** *******@microso ft.com>
<#S************ **@TK2MSFTNGP10 .phx.gbl>
<hY************ **@TK2MSFTNGXA0 1.phx.gbl>
<OF************ **@TK2MSFTNGP12 .phx.gbl>
<at************ **@TK2MSFTNGXA0 1.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.publi c.dotnet.framew ork.aspnet
| NNTP-Posting-Host: ip-206.159.118.137 .hdiss.net 206.159.118.137
| Path: TK2MSFTNGXA01.p hx.gbl!TK2MSFTN GP08.phx.gbl!tk 2msftngp13.phx. gbl
| Xref: TK2MSFTNGXA01.p hx.gbl
microsoft.publi c.dotnet.framew ork.aspnet:1351 71
| X-Tomcat-NG: microsoft.publi c.dotnet.framew ork.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******** ******@TK2MSFTN GXA01.phx.gbl.. .
| > Hi J,
| >
| > Thanks for your response.
| > I think this should be a page specific problems. Are you using the
| > httpwebRequest to programmaticall y 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********@new sgroups.nospam>
| > | From: <wa********@new sgroups.nospam>
| > | References: <Os************ *@TK2MSFTNGP10. phx.gbl>
| > <0E************ *************** *******@microso ft.com>
| > <#S************ **@TK2MSFTNGP10 .phx.gbl>
| > <hY************ **@TK2MSFTNGXA0 1.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.publi c.dotnet.framew ork.aspnet
| > | NNTP-Posting-Host: ip-206.159.118.137 .hdiss.net 206.159.118.137
| > | Path: TK2MSFTNGXA01.p hx.gbl!TK2MSFTN GP08.phx.gbl!TK 2MSFTNGP12.phx. gbl
| > | Xref: TK2MSFTNGXA01.p hx.gbl
| > microsoft.publi c.dotnet.framew ork.aspnet:1345 71
| > | X-Tomcat-NG: microsoft.publi c.dotnet.framew ork.aspnet
| > |
| > | Steven,
| > |
| > | I keep getting the following error:
| > |
| > | "The server committed a protocol violation. Section=Respons eHeader
| > 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.Ge tResponse(), HttpWebResponse )
| > |
| > | Dim rdrReader As System.IO.Strea mReader
| > |
| > | rdrReader = New System.IO.Strea mReader(webResp onse.GetRespons eStream)
| > |
| > | Dim responseHTML As String
| > |
| > | responseHTML = rdrReader.ReadT oEnd
| > |
| > | 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******** ********@TK2MSF TNGXA01.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 .GetResponseStr eam() method, e.g:
| > | >
| > | > HttpWebRequest request
| > | > ............... ............
| > | >
| > | > HttpWebResponse response = request.GetResp onse() as HttpWebResponse ;
| > | >
| > | > System.IO.Strea mReader reader = new
| > | > System.IO.Strea mReader(respons e.GetResponseSt ream());
| > | >
| > | > string reponseHTML = reader.ReadToEn d();
| > | >
| > | > 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********@new sgroups.nospam>
| > | > | From: <wa********@new sgroups.nospam>
| > | > | References: <Os************ *@TK2MSFTNGP10. phx.gbl>
| > | > <0E************ *************** *******@microso ft.com>
| > | > | 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.publi c.dotnet.framew ork.aspnet
| > | > | NNTP-Posting-Host: ip-206.159.118.137 .hdiss.net 206.159.118.137
| > | > | Path:
| > TK2MSFTNGXA01.p hx.gbl!TK2MSFTN GP08.phx.gbl!TK 2MSFTNGP10.phx. gbl
| > | > | Xref: TK2MSFTNGXA01.p hx.gbl
| > | > microsoft.publi c.dotnet.framew ork.aspnet:1341 57
| > | > | X-Tomcat-NG: microsoft.publi c.dotnet.framew ork.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(WebReques t.Create("https ://www.goemerchant 4.com/trans_center/gateway/d
| > | > irect.cgi"),
| > | > | HttpWebRequest)
| > | > |
| > | > | webReq.Method = "POST"
| > | > |
| > | > | webReq.ContentT ype = "applicatio n/x-www-form-urlencoded"
| > | > |
| > | > | Dim strInformation As String
| > | > |
| > | > | strInformation = "Merchant=17778 " & _
| > | > |
| > | > | "&OrderID=12345 67890" & _
| > | > |
| > | > | "&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=Jo hn Doe" & _
| > | > |
| > | > | "&Cardstreet=12 34 Happy Lane" & _
| > | > |
| > | > | "&Cardcity=Reno " & _
| > | > |
| > | > | "&Cardstate=Nev ada" & _
| > | > |
| > | > | "&Cardzip=89502 " & _
| > | > |
| > | > | "&Cardcountry=U S" & _
| > | > |
| > | > | "&CardexpM= 09" & _
| > | > |
| > | > | "&CardexpY= 06" & _
| > | > |
| > | > | "&CVV2=123" & _
| > | > |
| > | > | "&e************ **@test.com"
| > | > |
| > | > | Dim bytes As Byte() =
| > System.Text.Enc oding.UTF8.GetB ytes(strInforma tion)
| > | > |
| > | > | webReq.ContentL ength = bytes.Length
| > | > |
| > | > | Dim requestStream As System.IO.Strea m = webReq.GetReque stStream
| > | > |
| > | > | requestStream.W rite(bytes, 0, bytes.Length)
| > | > |
| > | > | requestStream.C lose()
| > | > |
| > | > | Thanks
| > | > |
| > | > | J
| > | > |
| > | > | "Robert Burdick [eMVP]"
| > <Ro************ ***@discussions .microsoft.com>
| > | > wrote
| > | > | in message
| > news:0E******** *************** ***********@mic rosoft.com...
| > | > | > using System.Net;
| > | > | > using System.IO;
| > | > | >
| > | > | > request = (HttpWebRequest )WebRequest.Cre ate(url);
| > | > | > request.Method = "POST";
| > | > | > request.Content Type = "applicatio n/x-www-form-urlencoded";
| > | > | > String data_to_post = "action=insert& first_name="+fi rst_name+.;
| > | > | > byte[] bytes = System.Text.Enc oding.UTF8.GetB ytes(data_to_po st);
| > | > | > request.Content Length = bytes.Length;
| > | > | > request_stream = request.GetRequ estStream();
| > | > | > request_stream. Write(bytes, 0, bytes.Length);
| > | > | > request_stream. Close();
| > | > | >
| > | > | > //Read the server response
| > | > | > response = (HttpWebRespons e)request.GetRe sponse();
| > | > | > .
| > | > | >
| > | > | >
| > | > | > "wa********@new sgroups.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="Customer s 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="NameonCar d"><Br>
| > | > | >> <input type="text" name="Cardstree t"><Br>
| > | > | >> <input type="text" name="Cardcity" ><Br>
| > | > | >> <input type="text" name="Cardstate "><Br>
| > | > | >> <input type="text" name="Cardzip"> <Br>
| > | > | >> <input type="text" name="Cardcount ry"><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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
3720
by: Kathy | last post by:
Can someone help me with the code to take the data in four fields on an HTML form and add it to a table in a database on an intranet. Thanks to all who help! Kathy
2
8403
by: Hazzard | last post by:
I just realized that the code I inherited is using all asp.net server controls (ie. webform controls) and when I try to update textboxes on the client side, I lose the new value of the textbox when submitting the form to update the database. The server doesn't have the client side value any more. It seems to me that as I begin to write the client side javacript code for form validation and client side editing capabilities in order to save...
17
2495
by: Lloyd Sheen | last post by:
This IDE is driving me nuts. I needed another button so I copied an existing one, changed the Text and the id and position by drag and drop. Well then I run and get the following: Control 'Button19' of type 'Button' must be placed inside a form tag with runat=server Can the IDE not do what it is supposed to do. It seems that it is a fight to make it do anything or did I do something wrong? It would seem silly to have to create a...
15
4778
by: Nathan | last post by:
I have an aspx page with a data grid, some textboxes, and an update button. This page also has one html input element with type=file (not inside the data grid and runat=server). The update button will verify the information that has been entered and updates the data base if the data is correct. Update will throw an exception if the data is not validate based on some given rules. I also have a custom error handling page to show the...
4
5330
by: Lee Chapman | last post by:
Hi, Can anyone tell me why in the code below, the call to ClearChildViewState() has no effect? To paraphrase the code: I'm using view state. I have a textbox and a submit button (and a label that can be ignored). When I press the button the first time, the click handler hides the textbox. Pressing the button a second time unhides the textbox. The text box is maintaining its value when hidden via view state. (The value is NOT being...
6
7390
by: john | last post by:
The standard method to transmit a file from an aspx page to a browser is to stream the file to the response then end the response. The HTML code generated by the aspx page is discarded, and the browser displays or offers to save the binary file instead. I would like to have the browser accept and display the revised HTML code as well as offering to open or save the attached file. This SHOULD be possible using a multipart MIME format -...
7
2791
by: thersitz | last post by:
I can't seem to get my html form to submit properly from within a web form. Here's my form tag syntax and some delivery hidden fields. <form id="myForm" action="https://xxx.order.net/xxx/cgi-bin/delivery.cgi" method="POST" onsubmit="return verify();"> <input type="hidden" name="recipient" value=me@mymail.net /> <input type="hidden" name="redirect" value="http://www.xxx.org/forms/confirmation.htm" /> .......................
7
3356
by: tapanreddy | last post by:
I am looking to perform an action when we close the window using the close tab at the top of the screen. I know how to do it using a close button but I was wondering if there is way to achieve the above. Waiting for some suggestions Thanks
19
248257
Atli
by: Atli | last post by:
Introduction At some point, all web developers will need to collect data from their users. In a dynamic web page, everything revolves around the users input, so knowing how to ask for and collect this data is essential to any developer. This article is a basic tutorial on how to user HTML Forms, the most common method of data collection. Assumptions - Basic HTML knowledge. - Basic PHP knowledge. HTML Forms A common and simple way of...
0
9579
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10205
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10035
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9984
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9851
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7401
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6662
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
2
3556
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2811
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.