[asp.net-mvc-2] A default document is not configured for the requested URL, and directory browsing is not enabled on the server

I have just deployed my asp.net mvc-2 website to a server (using dotnetpanel). But getting this error

A default document is not configured for the requested URL, and directory browsing is not enabled on the server.

What settings I needs? Its dotnetpanel based hosting server.

This question is related to asp.net-mvc-2 web-hosting

The answer is


Open IIS Setting in your plesk panel and enter default document name first page of website (deafault values are

 Index.html
Index.htm
Index.cfm
Index.shtml
Index.shtm
Index.stm
Index.php
Index.php3
Index.asp
Index.aspx
Default.htm
Default.asp
Default.aspx) 

This will work properly


The answer marked will help you eliminate the error but it will not get MVC working. The answer to the problem is to add this line to the web.config file in system.webServer:

<modules runAllManagedModulesForAllRequests="true" />

The culprit might lie in the fact that Global.asax has been placed in the wrong directory inside the mvc project. In my case it was placed under /Views but I had to move it should have been placed under the root folder of the project.

In your case you might be the exact opposite - run some tests and see for yourself.

https://stackoverflow.com/a/41467885/863651


I was having this issue in a WebForms application, the error clearly says that A default document is not configured and it was true in my case, the default document was not configured. What worked for me is that I clicked on my site and on the middle pane in iis there is an option named Default Document. In the Default Document you have to check if the default page of the application exists or not.

The default page of my application was index.aspx and it wasnt present on iis Default Document window. So I made a new entry of index.aspx and it started working.


Following applies to IIS 7

The error is trying to tell you that one of two things is not working properly:

  • There is no default page (e.g., index.html, default.aspx) for your site. This could mean that the Default Document "feature" is entirely disabled, or just misconfigured.
  • Directory browsing isn't enabled. That is, if you're not serving a default page for your site, maybe you intend to let users navigate the directory contents of your site via http (like a remote "windows explorer").

See the following link for instructions on how to diagnose and fix the above issues.

http://support.microsoft.com/kb/942062/en-us

If neither of these issues is the problem, another thing to check is to make sure that the application pool configured for your website (under IIS Manager, select your website, and click "Basic Settings" on the far right) is configured with the same .Net framework version (in IIS Manager, under "Application Pools") as the targetFramework configured in your web.config, e.g.:

<configuration>
  <system.web>
    <compilation debug="true" targetFramework="4.0" />
    <httpRuntime targetFramework="4.0" />
  </system.web>

I'm not sure why this would generate such a seemingly unrelated error message, but it did for me.


I know its too late to post answer, but i found completely differently scenario. I tried all possible solution given above but that not works for me. I found very silly mistake / ignorance in my case I checked IIS manager window carefully and found asp.net section was missing there. I have made Turn Windows features on for ASP.net, below is the steps

  1. Open Control Panel
  2. Programs\Turn Windows Features on or off Internet
  3. Information Services World Wide Web Services Application development
  4. Check for - >Features ASP.Net

I have closed IIS manager window and reopened it, now ASP.NET section is visible. enter image description here just browse hosted website and it's up on browser.


This can also occur if you do something stupid (like I did) and place the api url in the "Project Url" (e.g. http://localhost:59088/api/Product) on the Project Properties->Web tab instead of specifying it in the "Specific Page" text box. This causes Visual Studio to go ahead and create an APP called ProjectName/api/Product, and this will expect a default page. The only way to undo this is to go to C:\Program Files (x86)\IIS Express and use appcmd.exe to delete it like so

>.\appcmd.exe delete APP "ProjectName/api/Product"

Make sure you have your default page named as index.aspx and not something like main.aspx or home.aspx . And also see to it that all your properties in your class matches exactly with that of your table in the database. Remove any properties that is not in sync with the database. That solved my problem!! :)


In my case, I had to install the Microsoft.Owin.Host.SystemWeb package.

I was getting the same message as you did, but then noticed I couldn't even hit a breakpoint in Startup.cs which then let me to this SO thread.


Have you add a default route to this class?

public class RouteConfig {
    public static void RegisterRoutes (RouteCollection routes) {`
        //"HomePage" is the root view of your app
        routes.MapRoute (
            name: "Default",
            url: "{controller}/{action}/{id}",
            defaults: new {
                controller = "Home", action = "HomePage", id = UrlParameter.Optional
            }
        );
    }
}

` After that in Global.asax.cs add this line to Application_Start() method:

RouteConfig.RegisterRoutes (RouteTable.Routes);

I had this problem after I made an upgrade from MVC4 to MVC5 following this post and I had that line commented for a reason that I've forgot.

Hope this helps!


I faced the same error posted by OP while trying to debug my ASP.NET website using IIS Express server. IIS Express is used by Visual Studio to run the website when we press F5.

Open solution explorer in Visual Studio -> Expand the web application project node (StudentInfo in my case) -> Right click on the web page which you want to get loaded when your website starts(StudentPortal.aspx in my case) -> Select Set as Start Page option from the context menu as shown below. It started to work from the next run.

enter image description here

Root cause: I concluded that the start page which is the default document for the website wasn't set correctly or had got messed up somehow during development.