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

前端 未结 12 841
时光说笑
时光说笑 2020-12-13 03:37

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          


        
相关标签:
12条回答
  • 2020-12-13 04:12

    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

    0 讨论(0)
  • 2020-12-13 04:14

    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!

    0 讨论(0)
  • 2020-12-13 04:15

    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.

    0 讨论(0)
  • 2020-12-13 04:15

    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.

    0 讨论(0)
  • 2020-12-13 04:16

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

    0 讨论(0)
  • 2020-12-13 04:16

    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

    0 讨论(0)
提交回复
热议问题