Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.Net MVC 3/4 Hosted on IIS 7.5 Default Handler Mappings

What are the correct Default Handler Mappings for ASP.Net, ASP.Net MVC and WCF Services hosted on IIS 7.5 .Net Framework 4.0 on Windows 7 (PRO)?

Out of a team of 8 developers who installed ASP.Net MVC 3/4 only 1 developer could get a basic ASP.Net MVC 3 Internet application to work under the Default Web Site in IIS 7.5 without changing the Handler Mappings, none of the team could get a second Website with the same site to work with the site sirectory located in a sub directory of the root website. inetpub/wwwroot/site

Below are three of the Handler Mappings set in IIS 7.5 all are different and have not been changed by the developers.

What is the best way to define the required settings as Defaults and ensure all workstations have the same configurations applied without setting them in the Website Web.Config file?

enter image description here

enter image description here

enter image description here

like image 310
Lloyd Avatar asked Aug 16 '12 10:08

Lloyd


2 Answers

I successfully deployed MVC 4 to my local IIS 7.5 (windows 7). This fix my problem (as mentioned here)

(For x64 system)

%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_regiis.exe -i

(or if you in 32-bit system)

%windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_regiis.exe -i

Also, I changed the DefaultAppPool to use v4-Integrated (from v2-Classic), converted the website to application, and have the application to use DefaultAppPool.

Here is my complete Web.config. It has Handler included.

<?xml version="1.0" encoding="utf-8"?>

<compilation targetFramework="4.0" />

<pages>
  <namespaces>
    <add namespace="System.Web.Helpers" />
    <add namespace="System.Web.Mvc" />
    <add namespace="System.Web.Mvc.Ajax" />
    <add namespace="System.Web.Mvc.Html" />
    <add namespace="System.Web.Routing" />
    <add namespace="System.Web.WebPages" />
  </namespaces>
</pages>

<modules runAllManagedModulesForAllRequests="true" />

<handlers>
  <remove name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" />
  <remove name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" />
  <remove name="ExtensionlessUrlHandler-Integrated-4.0" />
  <add name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness32" responseBufferLimit="0" />
  <add name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness64" responseBufferLimit="0" />
  <add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
</handlers>

like image 196
Jeson Martajaya Avatar answered Oct 22 '22 08:10

Jeson Martajaya


Assuming that your default website has been configured as an application in IIS, the most likely cause of this issue is having the application pool running the Classic pipeline as opposed to the Integrated pipeline. In all of the MVC applications that we have deployed to Azure, local IIS servers and development machines, we have not had to touch the handler mappings unless having to trick IIS 6 into hosting an MVC site.

To check for the application pool pipeline:

  1. Open the IIS manager

  2. Right click on the Default Web Site, and choose Advanced Settings. This will open up a window enter image description here

  3. Note the name of the Application Pool. Now, close this window and click on Application Pools on the left hand menu in IIS manager enter image description here

  4. If the Managed Pipeline Mode is not set to Integrated (eg is reading classic), then right click the Application Pool and select basic settings. From here, you can change the Pipeline type. Choose integrated.

enter image description here

5.The application pool should immediately restart, but you can choose to restart it or IIS manually to ensure that your changes have taken affect.

Note - If you are running IIS 6, here is a link that describes how to adjust the handler mappings so that IIS 6 can run an MVC site.

Addendum - If you have been mucking with the handler mappings, depending on what has been changed, you may want to try this on a clean IIS install. It is not clear what handlers have been misconfigured as your team attempted to make an MVC deployment work.

like image 1
Tommy Avatar answered Oct 22 '22 09:10

Tommy