9

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

1
  • You need to allow Directory Browsing from IIS. Feb 15, 2017 at 5:13

3 Answers 3

19

You need to Allow Directory Browsing from IIS. Follow below steps to allow Directory Browsing.

  • Open IIS.
  • Select Your website from Left Pane.
  • Double click Directory Browsing from Right Pane/Center Pane.
  • In Right Pane under Actions Click Enable.
1
  • 3
    Followed all the following steps but doesn't work for me. Sep 22, 2020 at 7:46
2

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

1

You Need to Enable the Directory Browsing in IIS or else you can access only files by giving full path up to the file. Refer this link will show how

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.