MVC 3 Deployment to IIS6

2019-01-16 12:06发布

问题:

Originally, I deployed the site with some of the DLL's set to copy local (as haacked suggested on another SO post). After this failed, I installed MVC 3 package on the server.

When I hit my site I get:

Directory Listing Denied This Virtual Directory does not allow contents to be listed.

I saw haacked's blog, but its almost 3 years old now and some of it just doesn't work anymore. Does anyone know what we need to do to get this to work after we installed MVC 3 on the server?

UPDATE
I found another link on haacked's blog. Apparently, this should just work (no need to do wildcard mappings). My website virtual directory is set to run ASP.NET 4.0.30319, I have installed ASP.NET MVC 3, and I am running IIS6 (windows server 2003 R2, Pretty sure that is IIS6).

回答1:

The Virtual Directory was set to ASP.NET 4.0. While, the "Default Web Site" was set to run ASP.NET 2.0. I changed the "Default Web Site" to run 4.0 in addition to the virt. directory and it started working. The reason is a mystery to me, but it worked.



回答2:

It sounds like you haven't set up the wildcard mapping. You need to configure a mapping in IIS that sends all requests to ASP.NET pipeline for processing. Since you don't have the mapping set up, it interprets the request as a directory browse (which is probably disallowed in your configuration).

From Haacked:

  1. In the IIS properties for the website, click the Home Directory tab.
  2. Click the "Configuration..." button. In the "Mappings" tab, click "Insert..."
  3. Next to the "Wildcard application maps" label In the textbox, type in "c:\windows\microsoft.net\framework\v2.0.50727\aspnet_isapi.dll"
  4. Uncheck the box labeled "Verify that file exists" Click OK


回答3:

I believe ASP.NET 4 Extensionless URL feature is not working for virtual directory on iis v6 unless Default Web Site is also set to run ASP.NET v4.0. For me, setting ASP.NET v4.0 to Default Web Site is not an option since it's breaking existing v2.0 virtual directory webapps. Adding wildcard application maps on mvc3 virtual directory webapp worked for me. Here's the list of steps that I did to deploy mvc onto iis6.

  1. ASP.NET v4 is already installed on Windows 2003 server
  2. Install AspNetMVC3Setup.exe
  3. Copy the mvc3 webapp files onto server without mvc3 dlls in the bin folder
  4. Create Virtual Directory pointing to the app folder
  5. Set the ASP.NET version to 4.0.30319
  6. Add Wildcard application map to c:\windows\microsoft.net\framework\v4.0.30319\aspnet_isapi.dll and uncheck the Verify that file exists


回答4:

ABOUT WILCARD APPLICATION MAP: Be aware that this option causes IIS to intercept every request made against the web server. This includes requests for images, classic ASP pages, and HTML pages. Therefore, enabling a wildcard script map to ASP.NET does have performance implications.

OTHER SOLUTION: In W2K3 SP2 with IIS6, .NET Framework (2, 3.5, 4).

Goto Registry:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\ASP.NET\4.0.30319.0

If is necesary create DWORD EnableExtensionlessUrls with value 0.

Then from command window execute: resetiis

Create a ASP.NET application from MVC3 Template.

Now in the global.asax setup the routes like theses:

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

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

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

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

Create AppPool for .NET Framework 4 and setup the web application to use this apppool. You can use the Denis Bauer's ASP.NET Version Switcher or use Aspnet_regiis.exe.

RESULT: the browser shows de About page as the default page.