1

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

Matthew
  • 24,703
  • 9
  • 76
  • 110

3 Answers3

1

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

Martino
  • 52
  • 6
  • 1
    This is the most accurate answer, didn't really solve my problem however. Solution was to just include a "default.aspx" page that creates a new MvcHttpRequest. – Matthew Aug 23 '11 at 20:25
0

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.

Hector Correa
  • 26,290
  • 8
  • 57
  • 73
  • MVC2 doesn't use a default document, which is the problem. It provides all its routing through Global.asax file. – Matthew Nov 19 '10 at 16:38
  • No, I think the problem you are seeing is IIS, not the web site. Try adding a default document so that IIS knows what to route the request to when no document is indicated. After that your MVC routes will pick up the request. – Hector Correa Nov 19 '10 at 18:52
  • I did try that, it just loads the Default.aspx, and the route doesn't get picked up at all. – Matthew Nov 19 '10 at 19:22
  • That makes no sense. I've got nothing. Sorry. – Hector Correa Nov 19 '10 at 19:44
0

You can disable this behaviour on IIS6 and IIS7

// Disable IIS looking at physical files and directories
RouteTable.Routes.RouteExistingFiles = true;
arjan
  • 329
  • 2
  • 3