Problems with System.Net.WebClient

  • Thread starter Thread starter Pepe
  • Start date Start date
P

Pepe

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)
;
}

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."

I think that is going on because i haven't set up the right
credentials, ou authorisation to access the server... but, how can i do
it?

Can anybody help me?

Thanks
 
If it is just a matter of no authentication, you can simply set the
Credentials property to a new instance of a NetworkCredentials class that
contains your authentication information... unfortunately, I doubt that
authentication is your issue as a failure with that should result in an error
code of 401.

Given the error you are seeing, I would suggest doing some debugging on your
server side and attempt to figure out exactly why that is occurring there.
Any chance of enabling some logging on the page that is receiving your upload
POST?

Brendan
 
Brendan,

I can't do some debugging on the server side because i don't have the
right access to it. I can only deploy my web page over there.

I've tried to make these things with the credentials but it failed... I
don't know if i've done it right, can you give me an exemple?

The other suggestion that you gave me was to make some logging on the
page. That i can do.. i'll make the arrangements and as soon as i have
an answer i'll post it over here.

Thanks


Brendan said:
If it is just a matter of no authentication, you can simply set the
Credentials property to a new instance of a NetworkCredentials class that
contains your authentication information... unfortunately, I doubt that
authentication is your issue as a failure with that should result in an error
code of 401.

Given the error you are seeing, I would suggest doing some debugging on your
server side and attempt to figure out exactly why that is occurring there.
Any chance of enabling some logging on the page that is receiving your upload
POST?

Brendan


Pepe said:
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)
;
}

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."

I think that is going on because i haven't set up the right
credentials, ou authorisation to access the server... but, how can i do
it?

Can anybody help me?

Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top