开发者

The default document (default.aspx) in IIS is not working after adding MVC and routing to a WebForms project

I have an existing ASP.NET 3.5 WebForms project and have added ASP.NET MVC to the project. The existing pages work fine and so do the new controllers & views. However, whe开发者_开发百科n I deploy to IIS 7 the default document (default.aspx) is no longer working. I can get to it if I type it in explicitly but 'xyz.com' doesn't work - I get a 404. In contrast, it does work fine in Cassini.

How do I get the default document working again while still retaining the new MVC stuff.


I added the following to the Global.asx.cs file and the default document works again.

    public static void RegisterRoutes(RouteCollection routes)
    {
        // *** This Line ***
        routes.IgnoreRoute("");                                     // Required for the default document in IIS to work
        // *****************
        routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
        routes.IgnoreRoute("{resource}.aspx/{*pathInfo}");

        routes.MapRoute(
            "Default",                                              // Route name
            "{controller}/{action}/{id}",                           // URL with parameters
            new { controller = "Home", action = "Index", id = "" }  // Parameter defaults
        );
    }

    protected void Application_Start(Object sender, EventArgs e)
    {
        RegisterRoutes(RouteTable.Routes);
    }


Do you have Default Documents enabled for your IIS application, and is default.aspx in the list? Just double-check those, I can't think of anything else that would affect the serving of the default.aspx page. IIS should look something like this:

The default document (default.aspx) in IIS is not working after adding MVC and routing to a WebForms project

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜