By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,934 Members | 1,449 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,934 IT Pros & Developers. It's quick & easy.

Problems with System.Net.WebClient

P: n/a
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
Share this Question
Share on Google+
3 Replies


P: n/a

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

P: n/a
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

P: n/a

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 discussion thread is closed

Replies have been disabled for this discussion.