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

a 夏天 提交于 2019-12-05 03:43:20
Jeson Martajaya

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>

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

  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

  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.

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!