我希望能够在开发阶段从浏览器查看文件背后的代码。为此,我将在 web.config 中禁用.cs文件的默认处理程序。HttpForbiddenHandler
由于我使用的是 IIS 7,因此我首先将<remove>元素放在这样的<system.webServer>部分中:
<system.webServer>
    <handlers>
        <remove path="*.cs" verb="*"/>
        <add verb="*" path="*.cspx" type="HandlersAndModules.CspxHandler, HandlersAndModules" name="CspxHandler"/>
    </handlers>
</system.webServer>
运行应用程序时出现错误:
HTTP Error 500.19 - Internal Server Error
The requested page cannot be accessed because the related configuration data for the page is invalid.
这是因为 in <system.webServer>section 中的元素无法识别属性verb和path.
然后我尝试将  <remove>元素移动到<system.web>这样的部分:
<system.web>
    <httpHandlers>
        <remove path="*.cs" verb="*"/>
    </httpHandlers>
</system.web>
运行应用程序时出现错误:
HTTP Error 500.23 - Internal Server Error
An ASP.NET setting has been detected that does not apply in Integrated managed pipeline mode.
如何禁用HttpForbiddenHandler阻止.cs从浏览器查看文件的默认处理程序?