List Info

Thread: sending data to another server




sending data to another server
user name
2006-12-14 04:33:25
Hi friends..
am having one problem while reading an xml file and sending
the
contents by HTTP POST to another server..but i am facing the
error like


->Cannot send a content-body with this verb-type.<?xml
version="1.0"
encoding="utf-8"?>

am mentioning the code below..

            WebRequest webreq;
            WebResponse webres;
            webreq =
WebRequest.Create("ht
tp://localhost/test/Testupload/testxml.xml");

            webres = webreq.GetResponse();
            StreamReader sReader = new
StreamReader(webres.GetResponseStream());
            string strData = sReader.ReadToEnd();
            webres.Close();

            //Post data
            string querystring = strData.ToString();
            webreq.ContentType =
"multipart/form-data";
            webreq.Method = "POST";
            Stream strNewStream = webreq.GetRequestStream();
            byte[] temp_byteArray;
            temp_byteArray =(new
UnicodeEncoding()).GetBytes(querystring);
            strNewStream.Write(temp_byteArray, 0,
temp_byteArray.Length);
            strNewStream.Close();
            HttpContext.Current.Response.Write(querystring);

Kindly help me in solving the problem..In case am wrong in
the above
code then plz mention the correct way to solve the problem
as soon as
possible..


Regards       
Priyabrata


--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the
Google Groups "ASP.Net Community" group.
To post to this group, send email to aspnetgooglegroups.com
To unsubscribe from this group, send email to
aspnet-unsubscribegooglegroups.com
For more options, visit this group at http
://groups-beta.google.com/group/aspnet?hl=en
-~----------~----~----~----~------~----~------~--~---

[1]

about | contact  Other archives ( Real Estate discussion Medical topics )