Question

First let me explain that I am on a hosted solution, and there is not much I can do in ways of configuration and settings for IIS 6.

I have MVC2 working to a degree, I'm using the following Global.asax code:

    public static void RegisterRoutes(RouteCollection routes)
    {
        routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

        routes.MapRoute(
            "Default",
            "{controller}.aspx/{action}/{id}",
            new { action = "Index", id = "" }
        );

        routes.MapRoute(
            "Root",
            "",
            new { controller = "Default", action = "Index", id = "" }
        );
    }

In the first route, I had to specify {controller}.aspx, due to IIS 6 not being able to execute non aspx code (or something like that, not really sure).

Which is fine, the following works: hxxp://mysite.com/home.aspx, hxxp://mysite.com/projects.aspx, hxxp://mysite.com/contact.aspx

which are all controllers and I can run their respected actions as well.

The problem is that I can not do an empty URL properly (ie hxxp://mysite.com/), it gives me a "Directory Listing Denied" error.

The question I have, is with a default.aspx file located at root (which does execute), can I load the Home controller WITHOUT using a simple Response.Redirect?

Thank you, Matthew

Was it helpful?

Solution

The fact that you are getting "Directory Listing Denied" means that the isapi filetr don't match for working with MVC.

OTHER TIPS

The fact that you are getting "Directory Listing Denied" means that you don't have a default document and therefore the server is trying to show a list of files on the root folder.

Update the Default Document to something like "Default.aspx". Your hosting provider should have an option for this. This is very common.

You can disable this behaviour on IIS6 and IIS7

// Disable IIS looking at physical files and directories
RouteTable.Routes.RouteExistingFiles = true;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top