ChatGPT解决这个技术问题 Extra ChatGPT

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

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 ?

Is the project configured to use IIS? Or IIS Express? Or Casini?
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?
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.

N
NASSER

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>

I've been working on this project for months - never needed this line. I published the site today and it wouldn't run in debug anymore!!! Added this line makes it work again! I checked SVN - definitely never needed it before. WTF!? Thanks anyway, only wasted an hour :)
i am getting HTTP Error 500.22 - Internal Server Error.
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?
Sir... You saved my day! Thank you, this line solved my problem!
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..
m
muhammad waqas

This problem occurs because the Web site does not have the Directory Browsing feature enabled, and the default document is not configured. To resolve this problem, 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 method.

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

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 Directory Browsing. 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


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.
Method 2 worked for me as well. I am running php on iis and didn't add index.php.
S
Sadjad Khazaie

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


%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_regiis.exe -ir this worked for me for my 64bit system and MVC application
command for x64 also worked for me to solve that problem occured in my asmx web service
c
c24w

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

Steps

Type "turn windows features on or off" in search. Click on "Add Roles and features" in Server Manager. 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

https://i.stack.imgur.com/UgsIG.png

Finally hit next and Install. Restart IIS

Your website may start working.


This saved a hell of a time! Thanks so much!
C
Chamila Maddumage

I just pasted this code snippet inside web.config file and the error was solved.

<system.webServer>
    <directoryBrowse enabled="true" />
</system.webServer>

Just fyi - this is probably not what you want on any other server than your local computer.
u
user1566694

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.


L
Litisqe Kumar

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

<system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>

HTTP Error 500.22 - Internal Server Error
My issue resolved, after adding this code in webconfig file, thanks.
H
Hakan Fıstık

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

https://i.stack.imgur.com/fjAAu.png


R
Rinoy Ashokan

https://i.stack.imgur.com/Frl1x.png

I don't know whether this solution will help others.


J
JNYRanger

On the site in IIS:

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

https://docs.kentico.com/download/attachments/11272485/image2013-3-26%2012%3A40%3A38.png?version=1&modificationDate=1368524937706&api=v2


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.
S
Sain Pradeep

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.


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 ?
do you have default page in your website if not then create and set the default page as shown in this link iis.net/learn/web-hosting/web-server-for-shared-hosting/…
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.
H
Haktan Enes Biçer

I solved my problem with fallow this steps =>

Open IIS Manager Click the Application Click Directory Browsing Click Open Feature (On the right you will see under Actions) Click Enable


J
Jeremy Thompson

Problem

Error: 403.13 when running WebForms ASP.Net website from Visual Studio.

Solution

Access to the root is denied: http://localhost:51365

Navigate to the Login page or any page that exists and it will work:

http://localhost:51365/Login.aspx


r
rey_coder

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.


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.
E
Evandro

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)


That post doesn't actually answer this question since it's something like the other way around.
B
Blackbird

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.


A
Ahmed Adewale

https://i.stack.imgur.com/P0XtC.png


M
Mehdi Fracso

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


P
Protector one

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.


J
Justin Sinnard

I'm sure after years you probably have an answer already. But in case someone else is looking for an answer in the future.

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.

I'm posting a copy here as you're the first in the search query.


a
ashkufaraz

In my case

In Application Pool i set .NetFrameWork version to V4.0 and solved problem ....


A
Amir Parsi

https://i.stack.imgur.com/ukOuH.png


t
tkit

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


u
user1324491

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


K
Krishna

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

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

Try to change the application port to default. For example., Use http://localhost/ instead of http://localhost:25836/ 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.


C
ChinaHelloWorld

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.


g
gsm

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.

https://i.stack.imgur.com/Vt6yY.png