473,379 Members | 1,533 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,379 software developers and data experts.

Request.TotalBytes always 0

Hello,

I have an aspx page which is posting xml content to another asp.net
page, but the request.length is always 0. I think there should be
something there. below is the code for the requesting page and
consuming page. Does anyone have any insight? Thanks.

//CLIENT PAGE
string xml = "<foo />";
string uri = string.Concat("http://localhost/consume-req.aspx);

byte[] bytes = Encoding.UTF8.GetBytes(xml);
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri);

// integrated security
request.Credentials = CredentialCache.DefaultCredentials;

request.Method = "POST";
request.ContentLength = bytes.Length;
request.ContentType = "text/xml";
using (Stream requestStream = request.GetRequestStream())
{
requestStream.Write(bytes, 0, bytes.Length);
}
using (HttpWebResponse response =
(HttpWebResponse)request.GetResponse())
{
if (response.StatusCode != HttpStatusCode.OK)
{
string message = POST failed.";

}
else
{
// do something with the response
Stream stream = response.GetResponseStream();

// convert the response data into a string
StreamReader sr = new StreamReader(stream);
string results = sr.ReadToEnd();
sr.Close();

// end the request
stream.Close();
}
}
//****************************************
//CONSUME_REQ.ASPX
protected void Page_Load(object sender, EventArgs e)
{
try
{
//Process Request here
Stream stream = Request.InputStream;
long b = Request.InputStream.Length;
StreamReader sr = new StreamReader(stream);
string results = sr.ReadToEnd();

// Send the response
Response.Clear();
Response.ContentType = "text/xml";
Response.CacheControl = "No-cache";
Response.Expires = -1;
//oResponse.Save(new StreamWriter(Response.OutputStream));
}
catch (Exception ex)
{...}

Nov 2 '06 #1
0 1427

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

Similar topics

6
by: Christopher Brandsdal | last post by:
Hi! I get an error when I run my code Is there any other way to get te information from my form? Heres the error I get and the code beneath. Line 120 is market with ''''''''''''Line...
1
by: Nikhil | last post by:
I have a VBscript that I use to upload files onto the server. The script works fine on IIS 5.0 but on IIS 6.0 on Windows 2003 I get an error when uploading certain files. I believe its because the...
4
by: SP | last post by:
Hi I have a problem with a customer's XML being submitting to me in a non-well-format XML. They said that there are 18 other partners who has been able to tweak the XML to make it work. So I...
6
by: Daniel Rimmelzwaan | last post by:
I want to send a biztalk document to an aspx page, and I need to see some sample code, because I just can't make it work. I have a port with transport type HTTP, pointing to my aspx page, something...
4
by: Joel Cade | last post by:
I'm attempting to use an HTTP Module to monitor the progress of the request. Is there a way to do this? I've attempted to use the Request.TotalBytes property, and attempted to use the...
2
by: Water Cooler v2 | last post by:
Just trying to experiment with the Request.BinaryRead(count) method. What's wrong with this script? <SCRIPT Language="VBScript" runat="server"> Dim b b =...
0
by: kaczmar2 | last post by:
Hello, I have an aspx page which is posting xml content to another asp.net page, but the request.length is always 0. I think there should be something there. below is the code for the...
2
by: Griff | last post by:
Bizarre problem here.... I have a classic ASP web page that exists in one project. I have copied this code file into another web project and it errors! The code has not been altered in any...
0
skeptics
by: skeptics | last post by:
Trying to pass a SafeArray that i get form Request.BinaryRead Method in classic asp to a c# com interop component. In this thread i found a solution to pass and cast a normal asp safearray in to a c#...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
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...

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.