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

Problems with System.Net.WebClient

Hi!

I have a program that excutes the following code:

DirectoryInfo diretorio = new DirectoryInfo(@"C:\teste");
FileInfo[] arquivos = diretorio.GetFiles("*.xml");

for(int contador=0;contador<arquivos.Length;contador++)
{
lblMensagem.Text = "Uploading files... ";

ws.UploadFile("http://www.meusite.com.br/uploader.aspx","POST",arquivos[contador].FullName);
}

lblMensagem.Text = "Success!";

As you can see i've got a webpage that receives those files and saves on the
apropriate directory.

This code works when I'm running it on my machine. When I specify the link
to http://localhost/meusite/uploader.aspx the files are uploaded with no
errors but when i change the link to http://www.meusite.com.br/uploader.aspx
the following error appears:

"The remote server returned an error: (500) Internal Server Error."

Can anybody help me?

Thanks
--
Bruno
Sep 29 '05 #1
3 2451

It looks to me like you have not set the appropiate permissions so that the
ASPNET worker process can save the files to the directory. Change the
settings in your browser so you don't get "friendly errors" so you can see
the actual error message.

I don't remember off the top of my head, but I believe you have to add the
ASPNET account to the folder you intend to upload the files to and give it
full rights. Don't take my word for it though, find an article about it
online, it is not hard, just search for something like ".NET cannot upload
file".

Good luck!

--
Juan Romero
-----------------------------------------
The successful person has the habit of doing the things failures don't like
to do.
E.M. Gray
"Bruno Otero" wrote:
Hi!

I have a program that excutes the following code:

DirectoryInfo diretorio = new DirectoryInfo(@"C:\teste");
FileInfo[] arquivos = diretorio.GetFiles("*.xml");

for(int contador=0;contador<arquivos.Length;contador++)
{
lblMensagem.Text = "Uploading files... ";

ws.UploadFile("http://www.meusite.com.br/uploader.aspx","POST",arquivos[contador].FullName);
}

lblMensagem.Text = "Success!";

As you can see i've got a webpage that receives those files and saves on the
apropriate directory.

This code works when I'm running it on my machine. When I specify the link
to http://localhost/meusite/uploader.aspx the files are uploaded with no
errors but when i change the link to http://www.meusite.com.br/uploader.aspx
the following error appears:

"The remote server returned an error: (500) Internal Server Error."

Can anybody help me?

Thanks
--
Bruno

Sep 29 '05 #2
Thanks for your help Juan, but my problem isn't on the web site, i've some
other pages that uploads some files and they all work fine. The problem here
is with the Windows Forms that i've programmed to use the UploadFile method
from the System.Net.WebClient class.

--
Bruno
"Madestro" wrote:

It looks to me like you have not set the appropiate permissions so that the
ASPNET worker process can save the files to the directory. Change the
settings in your browser so you don't get "friendly errors" so you can see
the actual error message.

I don't remember off the top of my head, but I believe you have to add the
ASPNET account to the folder you intend to upload the files to and give it
full rights. Don't take my word for it though, find an article about it
online, it is not hard, just search for something like ".NET cannot upload
file".

Good luck!

--
Juan Romero
-----------------------------------------
The successful person has the habit of doing the things failures don't like
to do.
E.M. Gray
"Bruno Otero" wrote:
Hi!

I have a program that excutes the following code:

DirectoryInfo diretorio = new DirectoryInfo(@"C:\teste");
FileInfo[] arquivos = diretorio.GetFiles("*.xml");

for(int contador=0;contador<arquivos.Length;contador++)
{
lblMensagem.Text = "Uploading files... ";

ws.UploadFile("http://www.meusite.com.br/uploader.aspx","POST",arquivos[contador].FullName);
}

lblMensagem.Text = "Success!";

As you can see i've got a webpage that receives those files and saves on the
apropriate directory.

This code works when I'm running it on my machine. When I specify the link
to http://localhost/meusite/uploader.aspx the files are uploaded with no
errors but when i change the link to http://www.meusite.com.br/uploader.aspx
the following error appears:

"The remote server returned an error: (500) Internal Server Error."

Can anybody help me?

Thanks
--
Bruno

Sep 29 '05 #3

Bruno,

Your problem IS on the web site. The error message you posted is a response
from the server. The 500 code means there is something wrong with the
application you are running on the server. That is why it says "Internal
server error." Trust me, the error is happening on the server side. You may
be getting an error on your application, but that is probably because the
WebClient did not get a valid response from the server.
--
Juan Romero
-----------------------------------------
The successful person has the habit of doing the things failures don't like
to do.
E.M. Gray
"Bruno Otero" wrote:
Thanks for your help Juan, but my problem isn't on the web site, i've some
other pages that uploads some files and they all work fine. The problem here
is with the Windows Forms that i've programmed to use the UploadFile method
from the System.Net.WebClient class.

--
Bruno
"Madestro" wrote:

It looks to me like you have not set the appropiate permissions so that the
ASPNET worker process can save the files to the directory. Change the
settings in your browser so you don't get "friendly errors" so you can see
the actual error message.

I don't remember off the top of my head, but I believe you have to add the
ASPNET account to the folder you intend to upload the files to and give it
full rights. Don't take my word for it though, find an article about it
online, it is not hard, just search for something like ".NET cannot upload
file".

Good luck!

--
Juan Romero
-----------------------------------------
The successful person has the habit of doing the things failures don't like
to do.
E.M. Gray
"Bruno Otero" wrote:
Hi!

I have a program that excutes the following code:

DirectoryInfo diretorio = new DirectoryInfo(@"C:\teste");
FileInfo[] arquivos = diretorio.GetFiles("*.xml");

for(int contador=0;contador<arquivos.Length;contador++)
{
lblMensagem.Text = "Uploading files... ";

ws.UploadFile("http://www.meusite.com.br/uploader.aspx","POST",arquivos[contador].FullName);
}

lblMensagem.Text = "Success!";

As you can see i've got a webpage that receives those files and saves on the
apropriate directory.

This code works when I'm running it on my machine. When I specify the link
to http://localhost/meusite/uploader.aspx the files are uploaded with no
errors but when i change the link to http://www.meusite.com.br/uploader.aspx
the following error appears:

"The remote server returned an error: (500) Internal Server Error."

Can anybody help me?

Thanks
--
Bruno

Sep 29 '05 #4

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

Similar topics

11
by: ptass | last post by:
Hi I've installed win2k3 sp1 on a machine where an openRead on any given file was previously working. After installation, I get a webException as follows... ..message "An exception occurred...
2
by: xzzy | last post by:
I have .net 1.1 c# . . . . . using System.Net only lists sockets what do I need to do to be able to do: using System.Net.WebClient;
6
by: A.M-SG | last post by:
Hi, I have an aspx page at the web server that provides PDF documents for smart client applications. Here is the code in aspx page that defines content type: Response.ContentType =...
0
by: David W | last post by:
I am trying to upload a file from a user's system to my web server. I found code using the WebClient.UploadFile method. However, the uploaded file is from the server's hard drive not the user's...
0
by: Kumar | last post by:
Hi all, I have the following code which uses WebClient.UploadValues myNameValueCollection.Add("Name", name) myNameValueCollection.Add("Age", age) .............. ............. Dim web As New...
2
by: Jerry Spence1 | last post by:
I am trying to get a jpg image as follows: Dim Client As System.Net.WebClient = New System.Net.WebClient Client.DownloadFile("http://root:<password>@192.168.0.99/cgi-bin/video.jpg", MyFilename)...
3
by: df | last post by:
Hi, I'm trying to download the web page source code from a HTTPS URL, my code is as follows: Code: System.Net.WebClient WC = new System.Net.WebClient(); NetworkCredential Cred = new...
3
by: Giggi | last post by:
Hi! I need to pass some strings via an HTTP POST from page1 (in my app) to a page on another server. I stored my data in a NameValueCollection and then sent it using WebClient.UploadValues....
1
by: Mike | last post by:
I am using PowerShell to download an XML file into a string using the DownloadString(URI) method of System.Net.WebClient object. Sample commands below: $Result = $Null; $WebClient = new-object...
3
by: kpg | last post by:
(Multi-post from microsoft.public.dotnet.framework.aspnet.webservices, Please apply all applicable pardons.) Hi all, I have a web service that FTPs data it receives to a third party FTP site....
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: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...
0
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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,...

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.