简体   繁体   中英

IIS - 403 Forbidden: Access is denied when accessing a folder published through IIS 7.0

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

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 .

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM