Hi thanks for your reply as im really stuck here.
Actually im trying to upload files on the client site HTTPS enabled. the client certificate is also available and imported in the browser.
Now heres the code snippet that im using to achieve this functionality but its executes successfully and doesn't post any file.
- StreamReader srDel = new StreamReader("C:\\test.txt");
-
string sTestDelete = srDel.ReadToEnd();
-
srDel.Close();
-
-
string sDeleteURL = "https://sitename/folder";
-
-
byte[] AuthBytes = Encoding.ASCII.GetBytes("uname:password");
-
string sAuth = Convert.ToBase64String(AuthBytes);
-
HttpWebRequest Request = (HttpWebRequest)WebRequest.Create(sDeleteURL);
-
HttpWebResponse oResponse = null;
-
Request.Method = "POST";
-
-
Request.Headers.Add("ContentType", "text/xml");
-
Request.Headers.Add("Authorization", "Basic " + sAuth);
-
Request.Headers.Add("dev-t", " OurDevToken ");
-
Request.Headers.Add("UploadFor", "Marketplace");
-
-
System.Security.Cryptography.X509Certificates.X509Certificate ClientCertificate = new System.Security.Cryptography.X509Certificates.X509Certificate(@"C:\certificate.cer");
-
Request.ClientCertificates.Add(ClientCertificate);
-
-
byte[] SendByteArray = Encoding.GetEncoding(1252).GetBytes(sTestDelete);
-
Request.ContentLength = SendByteArray.Length;
-
-
Stream streamPostData = Request.GetRequestStream();
-
streamPostData.Write(SendByteArray, 0, SendByteArray.Length);
-
streamPostData.Close();
-
-
oResponse = (HttpWebResponse)Request.GetResponse();
-
StreamReader responseStream = new StreamReader(oResponse.GetResponseStream(), Encoding.ASCII);
-
string sResponse = responseStream.ReadToEnd();
-
-
Response.Write(sResponse);
-
-
oResponse.Close();
-
responseStream.Close();
-
Can you please tell me where im going wrong as the code executes fine without any exception but no file is uploaded.
Thanks!