Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

c#

iis-7

https

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

like image 319
Sachu Avatar asked Feb 15 '17 05:02

Sachu


1 Answers

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

like image 84
A Petrov Avatar answered Oct 05 '22 23:10

A Petrov