IIS6
如果这是 IIS6,那么很遗憾,无法通过您的 ASP.NET web.config 文件更改脚本映射设置。
您需要通过他们的控制面板找到允许此配置更改的托管服务商,或者要求您当前的托管服务商(很好地)为您更改此设置。
IIS7
如果这是 IIS7,那么您需要在您的 web.config 文件中添加(如果不存在)<system.webServer /> 配置部分并修改处理程序行为:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<handlers>
<!-- remove existing handlers -->
<remove name="PageHandlerFactory-ISAPI-2.0" />
<remove name="PageHandlerFactory-Integrated" />
<!-- add back but set resourceType="Unspecified" to prevent
checking if file exists -->
<add name="PageHandlerFactory-ISAPI-2.0"
resourceType="Unspecified"
path="*.aspx"
verb="GET,HEAD,POST,DEBUG"
modules="IsapiModule"
scriptProcessor="%windir%\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll"
requireAccess="Script"
preCondition="classicMode,runtimeVersionv2.0,bitness32"
responseBufferLimit="0" />
<add name="PageHandlerFactory-Integrated"
resourceType="Unspecified"
path="*.aspx"
verb="GET,HEAD,POST,DEBUG"
type="System.Web.UI.PageHandlerFactory"
preCondition="integratedMode" />
</handlers>
</system.webServer>
</configuration>
这仅在您的托管商已委派处理程序映射功能的读/写访问权限时才有效。
如果这是 IIS 7 并且 PageHandlerFactory-ISAPI-2.0 和 PageHandlerFactory-Integrated 处理程序配置为 resourceType="File" 或 resourceType="Either",我会感到相当惊讶。开箱即用,它们被配置为不检查文件和文件夹是否存在。