The remote server returned an error:(403) Forbidden

  • Thread starter Thread starter Nilay Shah
  • Start date Start date
N

Nilay Shah

Hi,

I am trying to connect to web page using following code:

client = new WebClient();
strURL = ConfigurationSettings.AppSettings
["strWebURL"].ToString();
client.DownloadFile
(strURL,ConfigurationSettings.AppSettings
["strSQLFileName"].ToString());


this part of code works on some machine and on some of the
maching I am receiving following error:
" The remote server returned an error: (403) Forbidden"

I am not able to understand why it works on some PC and
not on some. If you could help me solve the error then it
would be highly appreciated.

regards,
Nilay.
 
If that is a secured server, then the system may not be sending appropriate
credentials across the network. Can you access that file normally using IE,
or do you get prompted for a password?
 
I am able to see the file from IE without prompting for
password so I am sure that it is not secured server.. But
at the same time can u tell me which all places can I look
for the same..

I am more surprised because it is working from some other
PC.. Can u guide me which all setting can I compare of
both the PC..

regards,
nilay.
-----Original Message-----
If that is a secured server, then the system may not be sending appropriate
credentials across the network. Can you access that file normally using IE,
or do you get prompted for a password?

Nilay Shah said:
Hi,

I am trying to connect to web page using following code:

client = new WebClient();
strURL = ConfigurationSettings.AppSettings
["strWebURL"].ToString();
client.DownloadFile
(strURL,ConfigurationSettings.AppSettings
["strSQLFileName"].ToString());


this part of code works on some machine and on some of the
maching I am receiving following error:
" The remote server returned an error: (403) Forbidden"

I am not able to understand why it works on some PC and
not on some. If you could help me solve the error then it
would be highly appreciated.

regards,
Nilay.


.
 
You need to have specific credentials on the machine you're trying to access. I.e if ure trying to access localhost, make sure you have a USER ACCOUNT on that machine matching the credentials u're trying to use.

Also note: DO NOT TRY TO UPLOAD TO THE APPLICATION ROOT. You can only upload to a sub-folder.

So, if ure trying to upload to "http://www.monkeysauce.com", it wont work, but it will work if you upload to "http://www.monkeysauce.com/files".

WebClient myClient = new WebClient();
myClient.Credentials = new NetworkCredential("Mandarin", "mandarin");

myClient.UploadFile(@"http://localhost/files/dafile.tet","PUT",@textBox1.Text);
MessageBox.Show("Upload Complete!");

From http://www.developmentnow.com/g/34_...ote-server-returned-an-error403-Forbidden.htm

Posted via DevelopmentNow.com Groups
http://www.developmentnow.com
 
Back
Top