coure2011
coure2011

Reputation: 42454

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 I'm getting this error:

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

What settings do I need? It's a dotnetpanel-based hosting server.

Upvotes: 61

Views: 247049

Answers (12)

Rob King
Rob King

Reputation: 1201

The answer by UpTheCreek 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" />

Upvotes: 39

Pradeep atkari
Pradeep atkari

Reputation: 569

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.

Upvotes: 1

RBT
RBT

Reputation: 25917

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.

Upvotes: 15

Abhendra Tiwari
Abhendra Tiwari

Reputation: 19

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

Upvotes: 0

Fakhar Ahmad Rasul
Fakhar Ahmad Rasul

Reputation: 1691

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.

Upvotes: 0

Hawkeye Parker
Hawkeye Parker

Reputation: 8620

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.

Upvotes: 21

tkit
tkit

Reputation: 8622

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.

Upvotes: 0

XDS
XDS

Reputation: 4188

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

Upvotes: 0

Scott Baldwin
Scott Baldwin

Reputation: 431

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"

Upvotes: 1

bogdan.rusu
bogdan.rusu

Reputation: 943

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!

Upvotes: 2

Ozesh
Ozesh

Reputation: 6964

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

Upvotes: 0

UpTheCreek
UpTheCreek

Reputation: 32391

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

Upvotes: 42

Related Questions