473,499 Members | 1,589 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Upload a text file thru webclient

Hi
i am trying to upload a txt file thru this code, but its not updating
the data. is this code fine.
Or can anybody please suggest me some other meathod to do the same.
its urgent please help

regards
shantanu

WebClient client = new WebClient();
client.Credentials = netCred;
client.Headers.Add("Content-Type","application/x-www-form-
urlencoded");
client.UploadFile("http://aww.ngn.bel.alcatel.be/prp/cgi-bin/secure/
ImportForm.cgi","POST",@"C:\PRP\PRPTemp.txt");

Jun 20 '07 #1
12 2055
Hi,

It seems fine to me , what problems are you getting?

"shantanu" <sh***********@gmail.comwrote in message
news:11**********************@i38g2000prf.googlegr oups.com...
Hi
i am trying to upload a txt file thru this code, but its not updating
the data. is this code fine.
Or can anybody please suggest me some other meathod to do the same.
its urgent please help

regards
shantanu

WebClient client = new WebClient();
client.Credentials = netCred;
client.Headers.Add("Content-Type","application/x-www-form-
urlencoded");
client.UploadFile("http://aww.ngn.bel.alcatel.be/prp/cgi-bin/secure/
ImportForm.cgi","POST",@"C:\PRP\PRPTemp.txt");

Jun 20 '07 #2
On Jun 20, 5:28 pm, "Ignacio Machin \( .NET/ C# MVP \)" <machin TA
laceupsolutions.comwrote:
Hi,

It seems fine to me , what problems are you getting?

"shantanu" <shantanuse...@gmail.comwrote in message

news:11**********************@i38g2000prf.googlegr oups.com...
Hi
i am trying to upload a txt file thru this code, but its not updating
the data. is this code fine.
Or can anybody please suggest me some other meathod to do the same.
its urgent please help
regards
shantanu
WebClient client = new WebClient();
client.Credentials = netCred;
client.Headers.Add("Content-Type","application/x-www-form-
urlencoded");
client.UploadFile("http://aww.ngn.bel.alcatel.be/prp/cgi-bin/secure/
ImportForm.cgi","POST",@"C:\PRP\PRPTemp.txt");- Hide quoted text -

- Show quoted text -
hi thanx for the reply
i am really confused it is giving no error
can there be any posibility of acess rights
the link has GUI with a file upload option ans a import button.
regards
shantanu

Jun 20 '07 #3
From your description, this is a standard user page (since you mention
GUI); I'd be inclined to upload a file via a browser, with "fiddler"
running to see what gets sent - looking in particular at any
additional form variables, cookies, etc. You can probably get as much
by looking at the form, but "fiddler" may be easier, especially since
this is http not https (although fiddler 2 works with SSL in IE)

Marc
Jun 20 '07 #4
On Jun 20, 7:34 pm, "Marc Gravell" <marc.grav...@gmail.comwrote:
From your description, this is a standard user page (since you mention
GUI); I'd be inclined to upload a file via a browser, with "fiddler"
running to see what gets sent - looking in particular at any
additional form variables, cookies, etc. You can probably get as much
by looking at the form, but "fiddler" may be easier, especially since
this is http not https (although fiddler 2 works with SSL in IE)

Marc
Hi thanks for the reply but i actually did not get the answer, what is
fiddler ????
is it any tool that give me a strack trace of the communication?????

thanks shantanu

Jun 20 '07 #5
On Jun 21, 1:27 am, Marc Gravell <marc.grav...@gmail.comwrote:
Exactly:http://www.fiddlertool.com/Fiddler/version.asp
orhttp://www.fiddler2.com/fiddler2/

Marc
hi i tried with the fiddler tool
i am posting the trace can u tell whats the diffrence as i am not
getting it
++++++++++++++++++++++++++++++++++++++++++++++++++ +++++++++++++++++++++
++++++++++++++++
>From Excel
POST /prp/cgi-bin/secure/ImportForm.cgi HTTP/1.1

Content-Type: multipart/form-data;
boundary=---------------------8c981ff4727edcc

Content-Length: 1770

Expect: 100-continue

Host: aww.ngn.bel.alcatel.be

HTTP/1.1 100 Continue

-----------------------8c981ff4727edcc

Content-Disposition: form-data; name="file"; filename="PRPTemp.txt"

Content-Type: application/x-www-form-urlencoded

number.name.content.original.content.approved.cont ent.planned.contentdeleted.original.contentdeleted .approved.contentdeleted.planned.contentchange.ori ginal.contentchange.approved.contentchange.planned .defectsdoc.original.defectsdoc.approved.defectsdo c.planned.defectscode.original.defectscode.approve d.defectscode.planned.defectstest.original.defects test.approved.defectstest.planned.defectsval.origi nal.defectsval.approved.defectsval.planned.defects fieldsw.original.defectsfieldsw.approved.defectsfi eldsw.planned.effort.original.effort.approved.effo rt.planned.effortdr1dr5.original.effortdr1dr5.appr oved.effortdr1dr5.planned.defectsfielddr5.original .defectsfielddr5.approved.defectsfielddr5.planned. nrcustomers.original.nrcustomers.approved.nrcustom ers.planned.salesvalue.original.salesvalue.approve d.salesvalue.planned.margin.original.margin.approv ed.margin.planned.dr0p.original.dr0p.approved.dr0p .planned.dr0p.status.dr1.original.dr1.approved.dr1 .planned.dr1.status.dr3.original.dr3.approved.dr3. planned.dr3.status.dr4.original.dr4.approved.dr4.p lanned.dr4.status.dr5.original.dr5.approved.dr5.pl anned.dr5.status.dr6.original.dr6.approved.dr6.pla nned.dr6.status.dr0.original.dr0.approved.dr0.plan ned.dr0.status.dr2.original.dr2.approved.dr2.plann ed.dr2.status.ci.original.ci.approved.ci.planned.c i.status.obr.original.obr.approved.obr.planned.obr .status.releasetype.location.locationlead.pl.

9YZ-00490-
AAAA.TestProject.................................. .......................
2009-02-04....2009-12-12....2009-08-21....2009-09-19....2009-03-27.............L36051.
++++++++++++++++++++++++++++++++++++++++++++++++++ +++++++++++++++++++++
+++++++++++++++++
>From Portal
POST /prp/cgi-bin/secure/Import.cgi HTTP/1.1

Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg,
application/x-shockwave-flash, application/vnd.ms-powerpoint,
application/vnd.ms-excel, application/msword, application/xaml+xml,
application/vnd.ms-xpsdocument, application/x-ms-xbap, application/x-
ms-application, */*

Referer: http://aww.ngn.bel.alcatel.be/prp/cg...L36051&root=AL

Accept-Language: en-us

Content-Type: multipart/form-data;
boundary=---------------------------7d722727054c

Accept-Encoding: gzip, deflate

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)

Host: aww.ngn.bel.alcatel.be

Content-Length: 2155

Connection: Keep-Alive

Cache-Control: no-cache

Authorization: Basic c2hhbnRhbnUgc2VuOnN1bm55IzAwMw==

-----------------------------7d722727054c

Content-Disposition: form-data; name="file"; filename="C:\PRP
\PRPTemp.txt"

Content-Type: text/plain

number.name.content.original.content.approved.cont ent.planned.contentdeleted.original.contentdeleted .approved.contentdeleted.planned.contentchange.ori ginal.contentchange.approved.contentchange.planned .defectsdoc.original.defectsdoc.approved.defectsdo c.planned.defectscode.original.defectscode.approve d.defectscode.planned.defectstest.original.defects test.approved.defectstest.planned.defectsval.origi nal.defectsval.approved.defectsval.planned.defects fieldsw.original.defectsfieldsw.approved.defectsfi eldsw.planned.effort.original.effort.approved.effo rt.planned.effortdr1dr5.original.effortdr1dr5.appr oved.effortdr1dr5.planned.defectsfielddr5.original .defectsfielddr5.approved.defectsfielddr5.planned. nrcustomers.original.nrcustomers.approved.nrcustom ers.planned.salesvalue.original.salesvalue.approve d.salesvalue.planned.margin.original.margin.approv ed.margin.planned.dr0p.original.dr0p.approved.dr0p .planned.dr0p.status.dr1.original.dr1.approved.dr1 .planned.dr1.status.dr3.original.dr3.approved.dr3. planned.dr3.status.dr4.original.dr4.approved.dr4.p lanned.dr4.status.dr5.original.dr5.approved.dr5.pl anned.dr5.status.dr6.original.dr6.approved.dr6.pla nned.dr6.status.dr0.original.dr0.approved.dr0.plan ned.dr0.status.dr2.original.dr2.approved.dr2.plann ed.dr2.status.ci.original.ci.approved.ci.planned.c i.status.obr.original.obr.approved.obr.planned.obr .status.releasetype.location.locationlead.pl.

9YZ-00490-
AAAA.TestProject.................................. .......................
2009-02-04....2009-12-12....2009-08-21....2009-09-19....2009-03-27.............L36051.

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

Jun 21 '07 #7
The top one (I assume this is the one that doesn't work?) has no
Authorization header... this would be my first guess (although you
have set credentials...)

I was mainly looking for cookies and other form variables, but there
don't appear to be any in either ;-(

Marc

Jun 21 '07 #8
On Jun 21, 11:54 am, Marc Gravell <marc.grav...@gmail.comwrote:
The top one (I assume this is the one that doesn't work?) has no
Authorization header... this would be my first guess (although you
have set credentials...)

I was mainly looking for cookies and other form variables, but there
don't appear to be any in either ;-(

Marc
ya its really confusing

Jun 21 '07 #9
On Jun 21, 2:16 pm, shantanu <shantanuse...@gmail.comwrote:
On Jun 21, 11:54 am, Marc Gravell <marc.grav...@gmail.comwrote:
The top one (I assume this is the one that doesn't work?) has no
Authorization header... this would be my first guess (although you
have set credentials...)
I was mainly looking for cookies and other form variables, but there
don't appear to be any in either ;-(
Marc

ya its really confusing
Hi i got a stack trace related to uploading the data
HTTP/1.1 401 Authorization Required

Date: Fri, 22 Jun 2007 03:19:27 GMT

Server: Apache/2.0.49 (Unix) mod_perl/1.99_13 Perl/v5.8.4 PHP/4.3.7
DAV/2 mod_ssl/2.0.49 OpenSSL/0.9.7d

WWW-Authenticate: Basic realm="Corporate Internet Login "

Content-Length: 564

Content-Type: text/html; charset=iso-8859-1

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>401 Authorization Required</title>
</head><body>
<h1>Authorization Required</h1>
<p>This server could not verify that you
are authorized to access the document
requested. Either you supplied the wrong
credentials (e.g., bad password), or your
browser doesn't understand how to supply
the credentials required.</p>
<hr />
<address>Apache/2.0.49 (Unix) mod_perl/1.99_13 Perl/v5.8.4 PHP/4.3.7
DAV/2 mod_ssl/2.0.49 OpenSSL/0.9.7d Server at aww.ngn.bel.alcatel.be
Port 80</address>
</body></html>

but i am already using the code
WebClient client = new WebClient();
client.Headers.Add("Authorization","Basic
"+Convert.ToBase64String(Encoding.ASCII.GetBytes(" user:pass")));

client.Credentials = netCred;
client.Headers.Add("PreAuthenticate","true");
client.Headers.Add("Content-Type","application/x-www-form-
urlencoded");
client.UploadFile("http://aww.ngn.bel.alcatel.be/prp/cgi-bin/
secure/ImportForm.cgi?PL=L36051&root=AL","POST",@"C:\PRP
\PRPTemp.txt");

regards
shantanu

Jun 22 '07 #10
Well, from your stack trace it doesn't seem to be using it... I'm
confused as to why you are doubling up on setting headers anyway:
surely .Credentials should manage the Authorization header (so why set
twice?) Likewise, the content-type of a file upload isn't application/
x-www-form-urlencoded, but multipart/form-data. You don't should
netCred being initialized, but I can't see why this isn't playing
ball...

Marc
Jun 22 '07 #11
On Jun 22, 12:01 pm, Marc Gravell <marc.grav...@gmail.comwrote:
Well, from your stack trace it doesn't seem to be using it... I'm
confused as to why you are doubling up on setting headers anyway:
surely .Credentials should manage the Authorization header (so why set
twice?) Likewise, the content-type of a file upload isn't application/
x-www-form-urlencoded, but multipart/form-data. You don't should
netCred being initialized, but I can't see why this isn't playing
ball...

Marc
thanx marc
but any how is it possible that the server is not providing the
sufficient rights to upload the data in this way.I was reading in some
article that the portal should me deployed in a anonymous mode. Is it
true.??
regards
shantanu

Jun 22 '07 #12
On Jun 22, 2:10 pm, shantanu <shantanuse...@gmail.comwrote:
On Jun 22, 12:01 pm, Marc Gravell <marc.grav...@gmail.comwrote:
Well, from your stack trace it doesn't seem to be using it... I'm
confused as to why you are doubling up on setting headers anyway:
surely .Credentials should manage the Authorization header (so why set
twice?) Likewise, the content-type of a file upload isn't application/
x-www-form-urlencoded, but multipart/form-data. You don't should
netCred being initialized, but I can't see why this isn't playing
ball...
Marc

thanx marc
but any how is it possible that the server is not providing the
sufficient rights to upload the data in this way.I was reading in some
article that the portal should me deployed in a anonymous mode. Is it
true.??
regardsshantanu
Hi
I am still waiting for the resolution kindly help
regards
shantanu

Jul 2 '07 #13

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
9703
by: Shawn Mesiatowsky | last post by:
I have an html form that accepts a file for uploading, but I wanted to create a program to automate the upload procedure. I beileive you use the Webresponse class, but I was not sure how to use...
5
103449
by: John Lee | last post by:
Hi, I have a simple web page that allow file to be uploaded, the upload page looks like the following: <form method="post" name="upload" enctype="multipart/form-data"...
0
1268
by: Kannan | last post by:
Hello, I was trying to upload a local file on a client machine to a sharepoint folder using the WebClient object. This method is present in a client side DLL. I need to upload the document using...
3
2408
by: Brian | last post by:
Hi, I've been trying to find a way to upload file to another site that is not using IIS. The site that I want to upload file to has a simple php script to receive file uploaded through standard...
5
737
by: Neo | last post by:
Hello, I am receiving a file as a binary stream from a C++ Client Application. >From the application, the file is being sent as a "Multipart/form-data". I want to receive this file on the...
0
362
by: shantanu | last post by:
Hi i am trying to upload a txt file thru this code, but its not updating the data. is this code fine. Or can anybody please suggest me some other meathod to do the same. its urgent please help ...
5
3651
by: shantanu | last post by:
Hi i am trying to upload a txt file thru this code, but its not updating the data. is this code fine. Or can anybody please suggest me some other meathod to do the same. its urgent please help ...
21
34317
KevinADC
by: KevinADC | last post by:
Note: You may skip to the end of the article if all you want is the perl code. Introduction Uploading files from a local computer to a remote web server has many useful purposes, the most...
3
4283
by: =?Utf-8?B?dmFzaW1v?= | last post by:
Have the following code: wkLocalPath = "C:\A\1.jpg" wkServerPath = "http://servername/dirname/1.jpg" wcClient.Credentials = New NetworkCredential("UID", "PW") wcClient.UploadFile(wkServerPath,...
0
7009
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...
1
6899
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5475
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4919
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4602
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3103
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3094
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1427
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
665
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.