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

asp.net Mvc-2Web Hosting

asp.net Mvc-2 Problem Overview


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.

asp.net Mvc-2 Solutions


Solution 1 - asp.net Mvc-2

Which version of IIS is your host running? One thing to try is to put a dummy default.aspx file in the root folder (this will not be used when MVC is working, but can get rid of this problem).

Solution 2 - asp.net Mvc-2

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" />

Solution 3 - asp.net Mvc-2

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.

Solution 4 - asp.net Mvc-2

I faced the same error posted by OP while trying to debug an ASP.NET website using IIS Express server. IIS Express is a light-weight web server used by Visual Studio to run the website when we press F5 to debug website code.

How to fix it?

Open project solution in Visual Studio (VS) > Expand solution explorer > Expand the web application project node (StudentInfo in my case) > Right click on the web page which has to be loaded when website starts (StudentPortal.aspx in my case) > Select Set as Start Page option from the context menu as shown below.

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.

Solution 5 - asp.net Mvc-2

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!

Solution 6 - asp.net Mvc-2

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"

Solution 7 - asp.net Mvc-2

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.

Solution 8 - asp.net Mvc-2

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!! :)

Solution 9 - asp.net Mvc-2

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

Solution 10 - asp.net Mvc-2

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.

Solution 11 - asp.net Mvc-2

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.

Solution 12 - asp.net Mvc-2

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

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
Questioncoure2011View Question on Stackoverflow
Solution 1 - asp.net Mvc-2UpTheCreekView Answer on Stackoverflow
Solution 2 - asp.net Mvc-2Rob KingView Answer on Stackoverflow
Solution 3 - asp.net Mvc-2Hawkeye ParkerView Answer on Stackoverflow
Solution 4 - asp.net Mvc-2RBTView Answer on Stackoverflow
Solution 5 - asp.net Mvc-2bogdan.rusuView Answer on Stackoverflow
Solution 6 - asp.net Mvc-2Scott BaldwinView Answer on Stackoverflow
Solution 7 - asp.net Mvc-2Pradeep atkariView Answer on Stackoverflow
Solution 8 - asp.net Mvc-2OzeshView Answer on Stackoverflow
Solution 9 - asp.net Mvc-2XDSView Answer on Stackoverflow
Solution 10 - asp.net Mvc-2tkitView Answer on Stackoverflow
Solution 11 - asp.net Mvc-2Fakhar Ahmad RasulView Answer on Stackoverflow
Solution 12 - asp.net Mvc-2Abhendra TiwariView Answer on Stackoverflow