我们在某些开发人员工作站上遇到问题:访问没有文件名的网址(例如http://localhost/)时,IIS 7会返回404错误。每个人都在运行Windows 7 / IIS 7.5和ASP.NET 4.0。应用程序池配置为使用经典管道模式。
默认文档已启用,default.aspx位于默认文档列表中。
我启用了失败的请求跟踪,并在日志中看到了这一点:
OldHandlerName="", NewHandlerName="ExtensionlessUrl-ISAPI-4.0_64bit",
NewHandlerModules="IsapiModule",
NewHandlerScriptProcessor="C:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll", NewHandlerType=""
稍后,我看到这个IsapiModule拒绝了请求:
ModuleName="IsapiModule", Notification="EXECUTE_REQUEST_HANDLER", HttpStatus="404",
HttpReason="Not Found", HttpSubStatus="0",
ErrorCode="The operation completed successfully. (0x0)", ConfigExceptionInfo=""
看起来像 IIS认为ExtensionlessUrl-ISAPI-4.0-64bit应该处理请求。当我查看该模块的配置时,它显示它应该匹配路径*.
,所以我很困惑为什么它不匹配任何路径。
Google搜索从2005年开始this post on the IIS.net forums。不幸的是,没有提供任何解决方案,只是对此问题的确认。
当我更新自己的应用池以使用集成模式时,问题就会消失。不幸的是,它必须以经典模式运行。
如何让IIS再次为我们的默认文档提供服务?
答案 0 :(得分:22)
微软似乎发布了an update that enables the ExtensionlessURL HTTP handler to work with extensionless URLs。不幸的是,这打破了某些其他处理程序。在我的例子中,经典应用程序池下的DefaultDocument处理程序。解决方案是在我们的应用程序的web.config中删除ExtensionlessURL处理程序:
<system.webServer>
<handlers>
<remove name="ExtensionlessUrl-ISAPI-4.0_32bit" />
<remove name="ExtensionlessUrl-ISAPI-4.0_64bit" />
<remove name="ExtensionlessUrl-Integrated-4.0" />
</handlers>
</system.webServer>
答案 1 :(得分:15)
我在HandlerMapping中将“StaticFile”处理程序放在“ExtensionlessUrlHandler - *”之前解决了这个问题
答案 2 :(得分:1)
我注意到从应用程序池中删除托管的.NET框架(4.0)时,它也解决了我的问题!
我们在IIS环境中根本不使用.NET!
答案 3 :(得分:0)
在IIS中将默认文档设置为网站应用程序时,更改StaticFile顺序有助于解决问题,而根网站还有另一个默认文档。
答案 4 :(得分:0)
Adding the DefaultDocument component to IIS in add/remove windows features and then inserting the name of my default script ( index.php) worked for me.
答案 5 :(得分:0)
我在web.config URL Redirect中使用以下规则作为解决方法来解决此问题:
<system.webServer>
<rewrite>
<rules>
<rule name="Default document rewrite" stopProcessing="true">
<match url="^(.+/)?$" />
<action type="Redirect" url="https://{HTTP_HOST}/default.aspx" />
</rule>
</rules>
</rewrite>
</system.webServer>