473,386 Members | 1,734 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,386 software developers and data experts.

Upload/Download a File on HTTPS site in C#

Hi,
I'm searching for this solution from a long time now. i have a https protocol site from a client and i need to upload and download some files from my window service.
Now this site also requires a Client Certificate that i have already imported in my browser and through the browser i can easily access its folders.

Can anyone please tell me how can i make this possible using C# in my window service? I'm looking for its resolution very desperately.
Thanks!
Nov 21 '08 #1
7 11635
Its really strange that i'm googling the web and found many occurrences about this issue but NO RESOLUTION?
Is there anyone who can solve this issue?
Nov 21 '08 #2
joedeene
583 512MB
Are you just asking how to download and upload files on on https? Does this help: http://www.c-sharpcorner.com/UploadF...UsingHTTP.aspx.

joedeene
Nov 21 '08 #3
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.

Expand|Select|Wrap|Line Numbers
  1.         StreamReader srDel = new StreamReader("C:\\test.txt");
  2.         string sTestDelete = srDel.ReadToEnd();
  3.         srDel.Close();
  4.  
  5.         string sDeleteURL = "https://sitename/folder";
  6.  
  7.         byte[] AuthBytes = Encoding.ASCII.GetBytes("uname:password");
  8.         string sAuth = Convert.ToBase64String(AuthBytes);
  9.         HttpWebRequest Request = (HttpWebRequest)WebRequest.Create(sDeleteURL);
  10.         HttpWebResponse oResponse = null;
  11.         Request.Method = "POST";
  12.  
  13.         Request.Headers.Add("ContentType", "text/xml");
  14.         Request.Headers.Add("Authorization", "Basic " + sAuth);
  15.         Request.Headers.Add("dev-t", " OurDevToken ");
  16.         Request.Headers.Add("UploadFor", "Marketplace");
  17.  
  18.         System.Security.Cryptography.X509Certificates.X509Certificate ClientCertificate = new System.Security.Cryptography.X509Certificates.X509Certificate(@"C:\certificate.cer");
  19.         Request.ClientCertificates.Add(ClientCertificate);
  20.  
  21. byte[] SendByteArray = Encoding.GetEncoding(1252).GetBytes(sTestDelete);
  22. Request.ContentLength = SendByteArray.Length;
  23.  
  24. Stream streamPostData = Request.GetRequestStream();
  25. streamPostData.Write(SendByteArray, 0, SendByteArray.Length);
  26. streamPostData.Close();
  27.  
  28. oResponse = (HttpWebResponse)Request.GetResponse();
  29. StreamReader responseStream = new StreamReader(oResponse.GetResponseStream(), Encoding.ASCII);
  30. string sResponse = responseStream.ReadToEnd();
  31.  
  32.         Response.Write(sResponse);
  33.  
  34.         oResponse.Close();
  35.         responseStream.Close();
  36.  
Can you please tell me where im going wrong as the code executes fine without any exception but no file is uploaded.
Thanks!
Nov 21 '08 #4
Or is there any command line component is available for this purpose. Any work around to achieve this?
Nov 22 '08 #5
Still looking into this. Any suggestions or solution will highly be appreciated.
Thanks!
Nov 23 '08 #6
Is there anyone on this forum who knows this issue and can provide some technical help?
Nov 25 '08 #7
Going Disappointing from here. No resolution yet :(
Nov 27 '08 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Jonathan Wax | last post by:
Hi, I spent the last week looking for an answer to the following question: How can you upload an xml file to an HTTPS server with a specific certificate. Basically doing the same as this html...
0
by: CodeMotion | last post by:
I have access to an internet directory and files will be placed in this directory periodically. I am writing a service to poll that directory and download the files for processing. I have figured...
2
by: Jonathan Wax | last post by:
Hi, I spent the last week looking for an answer to the following question: How can you upload an xml file to an HTTPS server with a specific certificate. Basically doing the same as this html...
18
by: Jen | last post by:
I'm using Microsoft's own VB.NET FTP Example: http://support.microsoft.com/default.aspx?scid=kb;en-us;832679 I can get the program to create directories, change directories, etc., but I can't...
1
by: theburnetts | last post by:
I am building an ASP.NET application that has a requirement that the user should be able to download all of the data that they have input into the system and save it to a file on their local PC. ...
0
by: tom | last post by:
What I want to do is upload a zip file to an https website. The site itself uses secure File transport. Now webclient has the simplicity to upload a file, but I cannot attach the neccessary cert to...
0
by: Buddy Home | last post by:
Hello, I'm trying to upload a file programatically and occasionally I get the following error message. Unable to write data to the transport connection: An established connection was aborted...
1
by: jpandviv | last post by:
I'm looking to create an application which will allow me to upload a file using an encrypted/secure connection (SSL) and was looking to use the FileUpload control. This application will also allow...
2
by: =?Utf-8?B?SHVzYW0=?= | last post by:
Hi EveryBody: I'm working with project in my company by using ASP.Net 2.0 that allow the users to upload and download files to web site in the internet as backup. The user will first upload his...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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:
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?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.