Use Request to receive xml data that send by using HttpWebRequest,

Y

Ying-CO

Here are my sending data part of the code:
-----------------------------------
XmlTextWriter myWriter = null;
HttpWebRequest myRequest;

XmlTextReader myXMLReader = null;
XmlDocument myDoc = null;

myDoc = new XmlDocument();
myDoc = Miscellaneous.CreateXMLDoc(); // will return a xml doc

// post xml file
myRequest =
(HttpWebRequest)WebRequest.Create("http://localhost:2772/Default.aspx");

myRequest.Method = "POST";
myRequest.ContentType = "text/xml";
myRequest.KeepAlive = false;
try
{
myWriter = new
XmlTextWriter(myRequest.GetRequestStream(),System.Text.Encoding.UTF8);
//myDoc =
Miscellaneous.CreateXMLDoc(txtLogin.Text,SubmissionInfo.StrPasswd);
myDoc.WriteContentTo(myWriter);
myWriter.Flush();
myWriter.Close();
}.............

Here is my receving data code in Default.aspx.cs file
---------------------------------------------------------
// Get input from client
HttpContext con = Context;
HttpRequest httpReq = con.Request;
httpReq.ContentType = "text/xml";
httpReq.RequestType = "GET";

XmlTextReader myXMLReader = new
XmlTextReader(httpReq.InputStream);

if (httpReq.InputStream.Length != 0)
{
}

The problem is the length of httpReq.InputStream is 0. Can you tell me
what's wrong?

Thank you very much in advance,
Ying
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,534
Members
45,007
Latest member
OrderFitnessKetoCapsules

Latest Threads

Top