We published a folder through IIS 7.0 as below and put some files in it
https://www.example.net/mydocs
If we access the files as below through browser we are able to see it
https://www.example.net/mydocs/client.xml
https://www.example.net/mydocs/log.jpg
etc..
Now we need to write a pgm to download and upload files to this folder and we coded as below
WebClient webClient = new WebClient();
string webAddress = null;
try
{
webAddress = @"https://www.example.net/mydocs";
webClient.UseDefaultCredentials = true;
webClient.Credentials = CredentialCache.DefaultCredentials;
WebRequest serverRequest = WebRequest.Create(webAddress);
WebResponse serverResponse;
serverResponse = serverRequest.GetResponse();
serverResponse.Close();
webClient.UploadFile(webAddress + @"1.xml", "PUT", @"C:\d\1.xml");
webClient.Dispose();
webClient = null;
}
catch (Exception error)
{
MessageBox.Show(error.Message);
}
But it throwing and error at serverResponse = serverRequest.GetResponse();
The error is The remote server returned an error: (403) Forbidden.
Also if we try to access
https://www.example.net/mydocs
through browser we are getting the error
403 - Forbidden: Access is denied. You do not have permission to view this directory or page using the credentials that you supplied. when accessing the folder published through iis
In my experience it ended up being missing windows features installed.
I can't exactly point out which features are missing as I got tired of it and installed most of them, but that for sure solved my problem (and enabling directory browsing did not).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With