shantanu

shantanu

  • NA
  • 1
  • 2.6k

upload a text file using webclient

Jun 28 2007 4:49 AM

I am trying to upload a text file using webclient, but the site is not getting updated. I have also verified the stack trace, which show that the server has accepted the file and reetuned an OK notification. Kindly tell me what can be the possible issue that is restricting the update.
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Actual Senario
------------------------
i have a excel addin that will pick few values
from the excel sheet and form a text file that is compatible to the
upload format. Now i have a link of a web page that contains a file
control and a import button. on the click of the import button it
takes the file path as the parameter and invokes import.cgi script.
Now i have to upload a file thru this link using meathod like
webclient or any other meathod.

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

netCred =
new NetworkCredential(tbCIL.Text.Trim(),tbCIP.Text.Trim());

WebClient client = new WebClient();

client.Credentials = netCred;

client.Headers.Add("PreAuthenticate","true");

client.Headers.Add("Referer","http://aww.ngn.bel.alcatel.be/prp/cgi-bin/secure/ImportForm.cgi?PL=L36051&root=AL&Update=Yes");

client.Headers.Add("Accept-Language","en-us");

client.Headers.Add("Content-Type","application/x-www-form-urlencoded");

client.Headers.Add("Accept-Encoding","gzip, deflate");

client.Headers.Add("User-Agent","Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30)");

client.Headers.Add("Authorization","Basic c2hhbnRhbnUgc2VuOnN1bm55IzAwMw==");

client.UploadFile("http://aww.ngn.bel.alcatel.be/prp/cgi-bin/secure/Import.cgi","POST",@"C:\PRP\PRPTempUpload.txt");