473,383 Members | 1,843 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

my code is not sending post data to remote application using httpwebrequest .

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 =(HttpWebRequest)WebRequest.Create(lcUrl);

// *** Send any POST data
string lcPostData = "name=sanjay";
loHttp.Method = "POST";
loHttp.Headers.Add("key", "keyvalue");
loHttp.ContentType = "text/html";
byte[] lbPostBuffer = System.Text.Encoding.GetEncoding(1252).GetBytes(lc PostData);
byte[] getData = System.Text.Encoding.GetEncoding(1252).GetBytes("" );
loHttp.ContentLength = lbPostBuffer.Length;
Stream loPostData = loHttp.GetRequestStream();
loPostData.Write(lbPostBuffer, 0, lbPostBuffer.Length);
loPostData.Flush();
HttpWebResponse loWebResponse = (HttpWebResponse)loHttp.GetResponse();
Encoding enc = System.Text.Encoding.GetEncoding(1252);
StreamReader loResponseStream =new StreamReader(loWebResponse.GetResponseStream(), enc);
string lcHtml = loResponseStream.ReadToEnd();
MessageBox.Show(loWebResponse.ResponseUri.ToString ());
MessageBox.Show(lcHtml);
loWebResponse.Close();
loResponseStream.Close();
------------------------------------------------------------------------------------------------------------------

In this code i am sending a string "name" with value "sanjay" to my local server
http://localhost/check/WebSite3/Default.aspx.

I am writing this code on my application ---

-------------------------------------------------------------------------------------------------------------
Label1.Text = Request.Form("name")
--------------------------------------------------------------------------------------------------------------
but on the web page i am not getting any data by post.

but i am getting a proper respose from my remote application and on my windows application' msz box it is showing all the source code of my web application.

So plz tell me where my code is wrong and how i can send a proper value as a response to my calling application.
Apr 4 '07 #1
0 1504

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: PerryG | last post by:
We have a .NET 1.1 client which is sending a gzipped soap request using HttpWebRequest to an Apache server. The Apache server is using a the 'mod_deflate' server to decompress the incoming...
5
by: John Lee | last post by:
Hi, I have a simple web page that allow file to be uploaded, the upload page looks like the following: <form method="post" name="upload" enctype="multipart/form-data"...
6
by: Dan McCollick | last post by:
Hi All, I have a very small screen scrape application, that has a small problem. when I run the app and I have fiddler(an http tool to view what is being sent by the requests/responses,...
5
by: Tammy | last post by:
Hi, I have an aspx app which needs to post data to a form and read the response. I am confused on whether I should be using the get_url using "POST" method or the post_url using "GET" method. ...
3
by: Beryl Small | last post by:
Hi, I have a third party software that needs to send information to an .aspx page for processing to communicate with an SQL database. The software sends the information something like this: ...
13
by: Michael Tissington | last post by:
I have a web page that posts back to the server with credit card information. I then need to POST the information to my payment processing gateway, check the result and then send information...
3
by: Tom | last post by:
Hi. After I got some information from the user I need to POST it in XML format to the server NOT MY SERVER - a server at https://xxxx.xxx and to reveive the response. Please let me know...
7
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"...
0
by: gnewsgroup | last post by:
Sorry for the cross-post. I do have this posted in the aspnet security group. I notice there are a lot of "persecution" spams over there and I am afraid my post will be innundated. So, here it is....
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.