198

I just created a new empty website in Visual Studio 2012 and clicked on run (i.e view in browser) and I get this error:

HTTP Error 403.14 - Forbidden
The Web server is configured to not list the contents of this directory.

I went into IIS and clicked on Directory browsing and then ensured that Directory browsing was enabled but I still get this error. I can't figure it out?

The website project I just created is not listed in Default web sites in IIS Manager which I thought was odd.

How do I get rid of this error?

TylerH
  • 20,799
  • 66
  • 75
  • 101
Aindriú
  • 3,560
  • 9
  • 36
  • 54
  • Is the project configured to use IIS? Or IIS Express? Or Casini? – Kris Vandermotten Sep 24 '13 at 12:05
  • Did you **run** or **view in browser**? 2 different things. If this is an MVC project, then you might have tried to view a `view` in a browser? – Christian Phillips Sep 24 '13 at 12:10
  • 3
    Please make sure that you enabled *ASP.NET 4.5 or ASP.NET* from *Control Panel\All Control Panel Items\Programs and Features\Turn Windows Features on or off\Internet Information Services\World Wide Web Services\Application Developement Features\ASP.NET 4.5 or ASP.NET 3.5* depending upon your Application pool settings. – Bimal Das Jan 09 '18 at 06:45

24 Answers24

168

keep this into your web config file then rename the add value="yourwebformname.aspx"

<system.webServer>
    <defaultDocument>
       <files>
          <add value="insertion.aspx" />
       </files>
    </defaultDocument>
    <directoryBrowse enabled="false" />
</system.webServer>

else

<system.webServer>
    <directoryBrowse enabled="true" />
</system.webServer>
NASSER
  • 5,900
  • 7
  • 38
  • 57
  • i am getting HTTP Error 500.22 - Internal Server Error. – Bryan Labuschagne Sep 26 '17 at 08:44
  • 1
    This achieved nothing but wasting my time. Yeah, sure the aspx page loads but what good does that do me when it provides no access to my application? – Ortund Oct 14 '20 at 15:42
  • it was working until I changed web.config.. so issue shows up. Changed web.config back to original with no avail. Added suggested option works.. – jay fall Jul 02 '21 at 12:51
55

This problem might occur because the Web site does not have the Directory Browsing feature enabled, and the default document is not configured. To resolve this, use one of the following methods. To resolve this problem, I followed the steps in Method 1 as mentioned in the MS Support page and its the recommended one.

Method 1: Enable the Directory Browsing feature in IIS (Recommended)

  1. Start IIS Manager. To do this, click Start, click Run, type inetmgr.exe, and then click OK.

  2. In IIS Manager, expand server name, expand Web sites, and then click the website that you want to modify.

  3. In the Features view, double-click Directory Browsing.

  4. In the Actions pane, click Enable.

If that does not work for, you might be having different problem than just a Directory listing issue. So follow the below step,

Method 2: Add a default document

To resolve this problem, follow these steps:

  • Start IIS Manager. To do this, click Start, click Run, type inetmgr.exe, and then click OK.
  • In IIS Manager, expand server name, expand Web sites, and then click the website that you want to modify.
  • In the Features view, double-click Default Document.
  • In the Actions pane, click Enable.
  • In the File Name box, type the name of the default document, and then click OK.

Method 3: Enable the Directory Browsing feature in IIS Express

Note This method is for the web developers who experience the issue when they use IIS Express.

Follow these steps:

  • Open a command prompt, and then go to the IIS Express folder on your computer. For example, go to the following folder in a command prompt: C:\Program Files\IIS Express

  • Type the following command, and then press Enter:

    appcmd set config /section:system.webServer/directoryBrowse /enabled:true

Lucky
  • 16,787
  • 19
  • 117
  • 151
  • 2
    This should be accepted answer. Method 2 worked for me. Initially I created empty website, and then added a webform named "WebForm1.aspx". Hence I need to add that name in the default document list. Thank you. – novato Jan 04 '20 at 11:37
  • Method 2 worked for me as well. I am running php on iis and didn't add index.php. – jumptiger13 Jun 24 '22 at 17:18
35

Go to cmd and type this:

for x64 O.S: %windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_regiis.exe -ir

for x32 O.S: %windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_regiis.exe -ir

This will install the right version and IIS will understand the MVC directory browsing

Sadjad Khazaie
  • 2,102
  • 22
  • 22
  • 1
    %windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_regiis.exe -ir this worked for me for my 64bit system and MVC application – Amar Gadekar Oct 03 '19 at 08:19
  • command for x64 also worked for me to solve that problem occured in my asmx web service – Cavid Nov 14 '19 at 07:47
32

There can be multiple reasons for the issue. One that worked for me on IIS 8.5 was as follow

Steps

  1. Type "turn windows features on or off" in search.
  2. Click on "Add Roles and features" in Server Manager.
  3. In Wizard scroll down to the Web server and select : Web Server -> Application Development. Select all except CGI from the list as shown in the screen shot

enter image description here

  1. Finally hit next and Install.
  2. Restart IIS

Your website may start working.

c24w
  • 7,421
  • 7
  • 39
  • 47
satish suthar
  • 369
  • 3
  • 7
21

Set a start page.

When I had this problem, I went into the solution explorer, found the page I wanted to see first (in my case "Home.aspx), right clicked on it and selected "Set As Start Page." This fixed my issue (which sounded really similar to yours). This was in Visual Studio 2012 Professional and I ran it in Firefox.

user1566694
  • 1,363
  • 2
  • 13
  • 21
joshmcode
  • 3,471
  • 1
  • 35
  • 50
21

Control Panel > Turn Windows Features on or off

Internet Information Services > World Wide Web Services > Application Development Features

Enable the two options

.NET Extensibility 3.5
.ASP.NET 3.5

enter image description here

Hakan Fıstık
  • 16,800
  • 14
  • 110
  • 131
18

Try to add the following settings to web.config file.

<system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
Litisqe Kumar
  • 2,512
  • 4
  • 26
  • 40
9

Empty website template creates an ASP.NET website that includes a Web.config file but no other files. Means you have not any default page to show on browse or run.

This error message simply means that you did not setup and configure the default document properly on your IIS.

Once this is configured, the error message will go away.

Sain Pradeep
  • 3,119
  • 1
  • 22
  • 31
  • I did add a master page to the empty website and when I clicked run with no code I still got an error. I am not sure what I need to do in order to get it running ? – Aindriú Sep 24 '13 at 12:25
  • do you have default page in your website if not then create and set the default page as shown in this link http://www.iis.net/learn/web-hosting/web-server-for-shared-hosting/default-documents – Sain Pradeep Sep 24 '13 at 12:27
  • No I didn't have a default page in the empty website. I am following an example in a C# book. I added a default page and the page would load up in the web browser ok. But the example was only using master pages. I don't understand why it is not working. Its a very simple example. – Aindriú Sep 24 '13 at 14:50
9

On the site in IIS:

  1. select 'Advance Settings'
  2. Then for application pool choose "ASP.NET v4.0"

image for example

JNYRanger
  • 6,829
  • 12
  • 53
  • 81
WantToDo
  • 401
  • 1
  • 5
  • 11
  • 3
    This does not answer OP's question. Changing the Application Pool used by a site in IIS does not have any affect on how the site is configured to list directory contents (or not list them). This has to do instead with the configuration in the web.config file. – JNYRanger May 10 '15 at 15:26
7

This is because access to the root is denied. For example, for http://localhost:51365, navigate to the Login page (or any page that exists) and it will work:

http://localhost:51365/Login.aspx

TylerH
  • 20,799
  • 66
  • 75
  • 101
Jeremy Thompson
  • 61,933
  • 36
  • 195
  • 321
  • This is essentially a workaround for the problem, which is that opening the root URL of the project does not work, but should. – TylerH Jan 03 '23 at 19:34
6

For my case, I received the same error after creating an empty Web Api project.

I solved it by editing RouteConfig.cs in the App_Start folder :)

I replaced the line of code reading :-

defaults: new { action = "Index", id = UrlParameter.Optional }

with the following :-

defaults: new { controller = "Index", action = "Index", id = UrlParameter.Optional }

Notice I just had to specify the Controller whose index action I would like to invoke first.

Well all the above responses didn't solve my case (as I wanted) e.g.

  • Enabling directory browsing from web.config just listed all files and folders in my project just like php would do when you don't have an index file
  • Setting defaultDocument also didn't work for me somehow still got the HTTP Error 403.14 (Still have no idea why)

If there may be anyone in similar circumstances as mine then give this a try.

rey_coder
  • 422
  • 8
  • 12
  • 1
    This was most of the answer I needed. The controller name however has to match what was created for an MVC application Controller name (If you call your controller IndexController then it would work) - so the action name default on a controller should be Index and then it all gets tied together - the suggestions to use directory browsing is NOT a good idea in my opinion as it allows anyone to navigate your site contents in its entireity. – Mark W. Mitchell Sep 23 '17 at 18:46
6

I was getting this error and change the Application Pool Managed Pipeline Mode to "Integrated" solves the problem.

Source: Running a .NET 4.6 MVC application on IIS 8.5 (Windows Server 2012)

Evandro
  • 71
  • 1
  • 3
5

In my case, I experienced this error because my webapp was .NET v4, and the application pool was configured for .NET v2.

Double-clicking on the application pool brings up a popup window, where we can select the desired version of .NET Framework.

Blackbird
  • 2,368
  • 4
  • 26
  • 41
5

SOLVED
Search "Windows Feature" on start ->
Click "turn features on and off" ->
Expand "Internet Information Services" and
Check every progrm in every subfolder and
Click "OK"
This will fix all your problems. enter image description here

Ahmed Adewale
  • 2,943
  • 23
  • 19
4

The problem may come from running the project from visual studio on IIS while being on the wrong opened tab on visual studio, so the solution is either opening the right tab (the webform you want to test on your browser) or as others suggested in the other answers, right click on the webform that you want to set as a homepage then click on 'Set As A Start Page'.

Mehdi Fracso
  • 448
  • 2
  • 16
3

This can be caused by a bum applicationhost.config entry.

Stop IIS Express if it's running (right-click the light-blue scroll-thingy icon in the Windows System Tray; Exit).

Go to your project's Properties > Web, and check that the Project Url is correct. In case of an https url, make sure it includes a port number in the valid range. A correct URL could be: https://localhost:44300/. Now press the "Create Virtual Directory"-button next to the URL. This adds a new entry to applicationhost.config.

Start the project again and hopefully you will no longer get the error.

Protector one
  • 6,926
  • 5
  • 62
  • 86
3

For my problem, I didn't have to at anything to the web.config. I didn't think I would need to either as it was working previously.

Make sure no folder is named the same as your page, I had a folder called "blog" and a page named "blog.aspx", it was trying to load the folder, I noticed this in the link, changed the folder to blogContent, now it loads fine.

TylerH
  • 20,799
  • 66
  • 75
  • 101
2

In my case I was missing the Microsoft.Owin.Host.SystemWeb nuget.

tkit
  • 8,082
  • 6
  • 40
  • 71
2

right click on your project in solution explorer and then click add new item, add a HTML page and name it as index.HTML after all rerun your application

user1324491
  • 147
  • 4
2

Go to "Windows Feature" Click "turn Windows features on and off" Expand "Internet Information Services" and select .net Extensibility. more details please see pictureTurn Windows feature on or off

1

This could happen for any number of reasons. If you have tried through all of the above and still getting the same error, I have one more solution.

Another reason this could happen is that

  1. If you have the same code base running before you started to run the fresh solution, you might encounter this error. The reason is that IIS Express is trying to run on the same port as it was for the old solution which has the physical path registered for the application start URL.
  2. Since the IIS cannot figure out the physical path to run the solution, it might not be able to locate all the dlls required to start the application.

Solutions:

  1. Try to change the application port to default. For example., Use http://localhost/ instead of http://localhost:25836/

  2. Try changing to any other port if you have already used the default port for the previous application. ex: http://localhost:25364/ instead of http://localhost/

This will allow the IIS/IIS Express to point to the default bin path of the newer application you are trying to run which will have all the required dlls to start the application.

Krishna
  • 115
  • 10
1

I open one old Asp.net webform (.Net Framework4.5)solution with Visual Studio 2019, has same issue. The solution quite simple, go to web project's properties-> Web-> checked "Override application root URL" -> assign another port number. Save the solution and run in debug mode again. Problem resolved.

ChinaHelloWorld
  • 1,007
  • 1
  • 12
  • 6
0

So this means the server can't process what you doing. (if you wanna use the index kinda thing ignore this answer)

For example, if you are instaling WordPress on windows iis, the server should be able to run .php files.

otherwise you will get these kinds of issues. So if it WordPress you can resolve that issue by installing PHP on that server using iis manager -> web platform installer.

enter image description here

gsm
  • 2,348
  • 17
  • 16
0

You probably do not have to fix anything If you are getting this Error when running a .Net framework web api project you likely are pointing at the root instead of an API endpoint. Change your start settings to launch to an existing endpoint. enter image description here