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.
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).
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" />
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 faced exactly the same error while trying to debug my ASP.NET website using IIS Express server which is used by Visual Studio when we press F5 to run the website.
Open solution explorer in Visual Studio -> Expand the web application project node (StudentInfo
in my case) -> Right click on the web page (StudentPortal.aspx
in my case) which I wanted to get loaded when my website starts -> Select Set as Start Page
option from the context menu as shown below. It started to work from the next run.
Root cause: I concluded that the start page which is essentially the default document for the website wasn't set correctly or had got messed up somehow during development.
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!
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!! :)
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.
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.
来源:https://stackoverflow.com/questions/4654547/a-default-document-is-not-configured-for-the-requested-url-and-directory-browsi