R
ramsamant
Hi,
I am trying to push XML files via HTTP using C#. I am using the free
Visual Studio Web Developer Express to do this. After transferring
about 10-15 files, randomly the files transfer fail and I get
[WebException: The remote server returned an error: (403) Forbidden.]
I've tried on XP as well as Win2003 Server
Thanks for any help
Ram
CODE TO SEND FILES.
StringBuilder sb = new StringBuilder();
byte[] bytes = Encoding.UTF8.GetBytes(xml);
HttpWebRequest request = (HttpWebRequest) WebRequest.Create(url);
request.Timeout = 300000;
request.Method = "POST";
request.ContentLength = bytes.Length;
request.ContentType = "text/xml";
using (Stream requestStream = request.GetRequestStream())
{
requestStream.Write(bytes, 0, bytes.Length);
}
HttpWebResponse response = (HttpWebResponse) request.GetResponse();
CODE TO RECEIVE FILES
byte[] buf = new byte[Request.ContentLength];
buf=Request.BinaryRead(Request.ContentLength);
string s=Encoding.UTF8.GetString(buf);
StringReader sr=new StringReader(s);
DataSet ds=new DataSet();
ds.ReadXml(sr);
\ds.WriteXml(AppDomain.CurrentDomain.BaseDirectory + "/Received/" +
System.DateTime.Now.ToFileTimeUtc().ToString()+".xml");
I am trying to push XML files via HTTP using C#. I am using the free
Visual Studio Web Developer Express to do this. After transferring
about 10-15 files, randomly the files transfer fail and I get
[WebException: The remote server returned an error: (403) Forbidden.]
I've tried on XP as well as Win2003 Server
Thanks for any help
Ram
CODE TO SEND FILES.
StringBuilder sb = new StringBuilder();
byte[] bytes = Encoding.UTF8.GetBytes(xml);
HttpWebRequest request = (HttpWebRequest) WebRequest.Create(url);
request.Timeout = 300000;
request.Method = "POST";
request.ContentLength = bytes.Length;
request.ContentType = "text/xml";
using (Stream requestStream = request.GetRequestStream())
{
requestStream.Write(bytes, 0, bytes.Length);
}
HttpWebResponse response = (HttpWebResponse) request.GetResponse();
CODE TO RECEIVE FILES
byte[] buf = new byte[Request.ContentLength];
buf=Request.BinaryRead(Request.ContentLength);
string s=Encoding.UTF8.GetString(buf);
StringReader sr=new StringReader(s);
DataSet ds=new DataSet();
ds.ReadXml(sr);
\ds.WriteXml(AppDomain.CurrentDomain.BaseDirectory + "/Received/" +
System.DateTime.Now.ToFileTimeUtc().ToString()+".xml");