473,657 Members | 2,627 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

using HttpWebResponse to get POST variables

Hi all,

Fairly straight forward problem. I have a Post using HttpWebRequest
that posts data to a server. That server then posts data back to me.
Posting the data's not a problem, however I'm wondering if there is an
easy way to read back the variables that are returned. If not, I'm
left creating a parse routine which is not the end of the world but I
just want to be as programatically correct as I can be.

Code:

StreamReader sr = new StreamReader(Ht tpWResponse.Get ResponseStream( ),
System.Text.Enc oding.ASCII);
//Convert the stream to a string
string s = sr.ReadToEnd();
sr.Close();
Response.Write( s);

RETURNS:

s ="trnApproved=1 &trnId=10000843 &messageId=1&me ssageText=Appro ved&authCode=TE ST&errorType=N& errorFields=&av sProcessed=0&av sId=0&avsResult =0&avsAddrMatch =0&avsPostalMat ch=0&avsMessage =Address+Verifi cation+not+perf ormed+for+this+ transaction%2E"

I'd just like a way to read Request["trnApprove d"] or
Request["messageTex t"] - Any ideas?

Thanks,
DB
Nov 15 '05 #1
2 24697
I create a helper class , to strore the request array

using System;
using System.Collecti ons;
using System.Collecti ons.Specialized ;

namespace Erymuzuan.WinCo ntainer
{
/// <summary>
/// Summary description for BrowserInfo.
/// </summary>
public class BrowserInfo : NameObjectColle ctionBase
{
/// <summary> </summary>
private DictionaryEntry m_de = new DictionaryEntry ();

/// <summary>
/// ctor
/// </summary>
/// <example>
/// new BrowserInfo("my q=msa&sw=12&id= 1232");
/// </example>
/// <param name="postData" >query string pairs
/// </param>
public BrowserInfo(str ing postData)
{
string name;
string val;

foreach ( string s in postData.Split( '&'))
{
name = s.Substring(0, s.IndexOf("=") );
val = s.Substring(s.I ndexOf("=") + 1 , s.Length - (name.Length + 1));

// add it
BaseAdd(name, val);
}

}
/// <summary> Gets a key-and-value pair (DictionaryEntr y) using an
index.</summary>
public DictionaryEntry this[ int index ]
{
get
{
m_de.Key = BaseGetKey(inde x);
m_de.Value = BaseGet(index);
return( m_de );
}
}

//
/// <summary> Gets or sets the value associated with the specified
key.</summary>
public string this[ string key ]
{
get { return( BaseGet( key ).ToString() ); }
set { BaseSet( key, value ); }
}

//
/// <summary> Gets a String array that contains all the keys in the
collection.</summary>
public String[] AllKeys
{
get { return( this.BaseGetAll Keys() ); }
}

//
/// <summary> Gets an Object array that contains all the values in the
collection.</summary>
public Array AllValues
{
get { return( this.BaseGetAll Values() ); }
}

//
/// <summary> Gets a value indicating if the collection contains keys that
are not null.</summary>
public Boolean HasKeys
{
get { return( this.BaseHasKey s() ); }
}
/// <summary>
/// Adds an entry to the collection.
/// </summary>
/// <param name="key"></param>
/// <param name="value"></param>
public void Add( String key, Object value )
{
this.BaseAdd( key, value );
}

}// class
}
--
Erymuzuan Mustapa
Inter Virtual Sdn. Bhd.
See MIND at http://www.MIND.com.my

"David Billson" <da***********@ rtraction.com> wrote in message
news:9b******** *************** ***@posting.goo gle.com...
Hi all,

Fairly straight forward problem. I have a Post using HttpWebRequest
that posts data to a server. That server then posts data back to me.
Posting the data's not a problem, however I'm wondering if there is an
easy way to read back the variables that are returned. If not, I'm
left creating a parse routine which is not the end of the world but I
just want to be as programatically correct as I can be.

Code:

StreamReader sr = new StreamReader(Ht tpWResponse.Get ResponseStream( ),
System.Text.Enc oding.ASCII);
//Convert the stream to a string
string s = sr.ReadToEnd();
sr.Close();
Response.Write( s);

RETURNS:

s ="trnApproved=1 &trnId=10000843 &messageId=1&me ssageText=Appro ved&authCode=TE S
T&errorType=N&e rrorFields=&avs Processed=0&avs Id=0&avsResult= 0&avsAddrMatch= 0
&avsPostalMatch =0&avsMessage=A ddress+Verifica tion+not+perfor med+for+this+tr a
nsaction%2E"
I'd just like a way to read Request["trnApprove d"] or
Request["messageTex t"] - Any ideas?

Thanks,
DB

Nov 15 '05 #2
Since you are programatically going to another web page, chances are you are
doing this to get data? If so, and if you have control over it - the server
you are calling - should return XML. That way all your data will be nice and
organized when it do a GetResponseStre am(). Food for thought...
"David Billson" <da***********@ rtraction.com> wrote in message
news:9b******** *************** ***@posting.goo gle.com...
Hi all,

Fairly straight forward problem. I have a Post using HttpWebRequest
that posts data to a server. That server then posts data back to me.
Posting the data's not a problem, however I'm wondering if there is an
easy way to read back the variables that are returned. If not, I'm
left creating a parse routine which is not the end of the world but I
just want to be as programatically correct as I can be.

Code:

StreamReader sr = new StreamReader(Ht tpWResponse.Get ResponseStream( ),
System.Text.Enc oding.ASCII);
//Convert the stream to a string
string s = sr.ReadToEnd();
sr.Close();
Response.Write( s);

RETURNS:

s ="trnApproved=1 &trnId=10000843 &messageId=1&me ssageText=Appro ved&authCode=TE S
T&errorType=N&e rrorFields=&avs Processed=0&avs Id=0&avsResult= 0&avsAddrMatch= 0
&avsPostalMatch =0&avsMessage=A ddress+Verifica tion+not+perfor med+for+this+tr a
nsaction%2E"
I'd just like a way to read Request["trnApprove d"] or
Request["messageTex t"] - Any ideas?

Thanks,
DB

Nov 15 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
2107
by: Denny Rue | last post by:
I’ve created VB code to download files from a web site through the use of HTTPWebRequest, HTTPWebResponse and BinaryReader. The HTTPWebRequest has a TimeOut property to limit how long it waits for a corresponding HTTPWebResponse. This works just fine. However, the timeout does not appear to apply to a BinaryReader created from the HTTPWebResponse. I’ve had instances where the procedures will hang indefinitely during the download. ...
3
11285
by: Paul M | last post by:
Hi Sorry if this is posted in the wrong group but I'm brand new to this area. Basically I've got to post some XML documents to an external server using HTTP web request (POST, not GET) and be able to receive files back. I've got the XML file generated and checked over, but I just dont know how to go about the post process. I've got a feeling I'm supposed to create a form in my ASP application with an action which points at the URL I've...
1
5865
by: Vasu | last post by:
Hi, I have a requirement to download a file from the web site using a client tool. Iam writing a C# program to download using WebRequest, HttpRequest, WebResponse and so on. The problem Iam having is to navigate thru multiple pages. I have to login
0
9199
by: Peter Qian | last post by:
Hi, I'm working on a windows form based program that can log into a web service (Apache based, https is used for auth). I was able to post the login data and obtain a sessionID. However I'm not sure how to maintain this id over multiple requests. Here are my code: Globle Varibles private static int timeOut = 20000; private CookieContainer cookieContainer; /* other cookies */
0
3220
by: Anthony | last post by:
Hi all, I am just trying to set up a form post to worldppay and finding it surprisingly difficult.. What i would like is to gather all of the variables needed in c# codebehind and then send them along to worldpay along with the user.. Basically i dont want the user to have to submit a button it will do it automatically.. I have followed this code and i think it posts the data but wont take the user to the worldpay page as well
7
4251
by: | last post by:
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)">
7
17291
by: Mark Waser | last post by:
Hi all, I'm trying to post multipart/form-data to a web page but seem to have run into a wall. I'm familiar with RFC 1867 and have done this before (with AOLServer and Tcl) but just can't seem to get it to work in Visual Basic. I tried coding it once myself from scratch and then modified a class that I found on a newsgroup (referenced below). Both seem to be doing the same thing and neither works (or rather, they seem to work but the...
0
1522
by: sanjaygupta11 | last post by:
I am using httpwebrequest and httpwebresponse objects for sending data to remote appication by post and receiving the response from there. I am using this code in my windows application which will send a request to remote application. --------------------------------------------------------------------------------------------------------------- string lcUrl = "http://localhost/check/WebSite3/Default.aspx"; HttpWebRequest loHttp...
4
3334
by: JVNewbie | last post by:
I'm attempting to test an aspx module that will receive XML data from a web service (the receiver module). I want to be able to test this portion before attempting to create the Web Service that will generate the POST to this module. The "poster module" works fine but when I try to get the response back from the receiver module I get a "(500) Internal Server Error." and the module is never executed. I have added it to the same solution and also...
0
8732
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
8503
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
7324
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6163
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
5632
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();...
0
4151
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4302
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2726
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1611
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.