473,385 Members | 1,752 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,385 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 1254

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: Bingo | last post by:
Hi group ! I am trying to write an ASP page that would forward an XML request to a remote server, and then write the response to the client (a kind of proxy, if you like). I am sending 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: 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: 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
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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.