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

前端 未结 12 879
时光说笑
时光说笑 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条回答
  •  Happy的楠姐
    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!

提交回复
热议问题