views:

79

answers:

3

I have an Asp.Net MVC 2 web application deployed on IIS 7.5 on .Net 4.0. When I select application pool as Asp.Net v4.0 Classic I get the following error.

HTTP Error 403.14 - Forbidden
The Web server is configured to not list the contents of this directory.

The same application works fine when I select application pool as Asp.Net v4.0 Integrated. Does anyone know what is the reason for this?

Update: I followed the steps from the folowing url.

http://www.asp.net/mvc/tutorials/using-asp-net-mvc-with-different-versions-of-iis-cs

I have added a map for .mvc extension and also modified the Routing as shown below.

 routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

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


            routes.MapRoute(
                    "Root",
                    "",
            new { controller = "Home", action = "Index", id = "" }

Now the following url is working fine and I can see the Home/Index page.

http://myapp/home.mvc

But this still gives the same error (HTTP Error 403.14 - Forbidden)

http://myapp/

This should have worked since I have mapped the Root to Home/Index action.

+1  A: 

Its because the routing does not work in classic mode. There are some workarounds on the net, but most of them not working very well.

Here is some explanation and help on this topic: http://www.asp.net/mvc/tutorials/using-asp-net-mvc-with-different-versions-of-iis-cs

Any reason you dont want to use integrated?

Marks
To be clear: Routing *does* work, if it's invoked. The trick is to get ASP.NET into the picture *at all.* `System.Web.Routing` itself works fine.
Craig Stuntz
I have IIS 7.5 on my development machine but on Prod it is still IIS 6.0.
Amitabh
+1  A: 

With classic mode you need to either do a wildcard mapping or use the ".mvc" extensions on your controller names in the URIs. So you'd have to change the *.mvc mapping in your IIS ASP.NET configuration to . or change your default route to something like:

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

These methods certainly do work; indeed, it's the only way to support IIS 5-6. On the other hand, with IIS 7 I'd just use integrated mode.

Craig Stuntz
+2  A: 

Integrated refers to the IIS Integrated Pipeline mode: http://msdn.microsoft.com/en-us/magazine/cc135973.aspx

When integrated pipeline mode is off, the request for the URL you are entering is not routed to ASP.NET. Additionally, since there is no default.aspx or similar "default document" in the folder you're accessing, IIS defaults to attempting to list the directory's contents. By default, this setting is disabled in IIS, thus you receive the 403.13 Forbidden error.

MicScoTho
If you need to use ASP.NET MVC in IIS 6 or IIS 7 classic mode, see the "Using ASP.NET MVC with Older Versions of IIS" section of this page for detailed instructions. There are a few setups you can choose from: http://www.asp.net/mvc/tutorials/using-asp-net-mvc-with-different-versions-of-iis-cs
MicScoTho