如何让 IIS 7 将 .css 文件的请求路由到 aspnet_isapi.dll?

发布于 2024-11-08 17:19:55 字数 352 浏览 0 评论 0原文

目前,我们在 IIS 6 上托管的 ASP.NET Web 应用程序上使用 DotLess。为了使其正常工作,我们需要调整 IIS 设置,以便对 *.css 文件的请求由 aspnet_isapi.dll 处理(右键单击 IIS 中的网站 -> 属性 -> 主目录选项卡 -> 配置)。

我们现在正在将此 Web 应用程序移至 IIS 7(经典模式),但似乎找不到以这种方式设置 IIS 7 的方法。有没有办法更改 IIS 7 的设置,以便像我们在 IIS 6 中所做的那样,由 aspnet_isapi.dll 处理 *.css 文件的请求?

We currently use DotLess on an ASP.NET web application hosted on IIS 6. In order to get this to work, we needed to tweak our IIS settings so that requests for *.css files would get handled by aspnet_isapi.dll (right click on website in IIS -> properties -> home directory tab -> configuration).

We're now moving this web application over to IIS 7 (classic mode) and can't seem to find a way to set up IIS 7 in this manner. Is there a way to change IIS 7's settings so that requests for *.css files get handled by aspnet_isapi.dll like we were doing in IIS 6?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

甚是思念 2024-11-15 17:19:55

你看过这个链接吗?对你有帮助吗? http://learn. iis.net/page.aspx/508/wildcard-script-mapping-and-iis-7-integrated-pipeline/

实际上:IIS7 ->网站->处理程序映射 ->添加通配符脚本 在 IIS 7 经典管道模式中匹配

通配符脚本映射

使用经典管道模式,ASP.NET 作为 ISAPI 扩展插入 IIS 请求处理管道 - 与 IIS 6 中的方式完全相同。事实上,如果您打开 %WINDIR%\system32\inetsrv\config\applicationHost.config 文件并找到其中的部分,您可以看到 IIS 如何配置为将 ASP.NET 特定请求映射到aspnet_isapi.dll:

<handlers accessPolicy="Read, Script">
  ...
  <add name="PageHandlerFactory-ISAPI-2.0" 
       path="*.aspx" verb="GET,HEAD,POST,DEBUG" 
       modules="IsapiModule" 
       scriptProcessor="%windir%\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll" 
       preCondition="classicMode,runtimeVersionv2.0,bitness32" responseBufferLimit="0" />
  ...
</handlers>

注意处理程序映射的 preCondition 属性。除此之外,此属性设置为 classicMode,这确保此处理程序映射仅在应用程序池配置为在经典模式下运行时才生效。
现在,如果要为在经典模式下运行的 ASP.NET 配置通配符映射,可以通过在 IIS 管理器中选择“处理程序映射”,然后单击“添加通配符脚本映射...”操作来完成。

Have you seen this link? Does it help you? http://learn.iis.net/page.aspx/508/wildcard-script-mapping-and-iis-7-integrated-pipeline/

Effectively this: IIS7 -> Web Site -> Handler Mappings -> Add Wildcard Script Match

Wildcard script mapping in IIS 7 classic pipeline mode

With classic pipeline mode the ASP.NET is plugged into the IIS request processing pipeline as an ISAPI extension - exactly the same way as it was in IIS 6. In fact, if you open %WINDIR%\system32\inetsrv\config\applicationHost.config file and locate the section inside of it you can see how IIS is configured to map ASP.NET specific requests to the aspnet_isapi.dll:

<handlers accessPolicy="Read, Script">
  ...
  <add name="PageHandlerFactory-ISAPI-2.0" 
       path="*.aspx" verb="GET,HEAD,POST,DEBUG" 
       modules="IsapiModule" 
       scriptProcessor="%windir%\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll" 
       preCondition="classicMode,runtimeVersionv2.0,bitness32" responseBufferLimit="0" />
  ...
</handlers>

Notice the preCondition attribute for the handler mapping. Among other things this attribute is set to classicMode, which ensures that this handler mapping only takes effect when the application pool is configured to run in classic mode.
Now if you want to configure wildcard mapping for the ASP.NET running in classic mode, you can do it by choosing "Handler Mappings" in IIS Manager and then clicking on "Add Wildcard Script Map..." action.

月野兔 2024-11-15 17:19:55

定义一个 HttpHandler 并通过 web.config 将其连接到 iis,在本例中,我有一个名为 CssHandler 的类,它实现了 IHttpHandler 接口。

<configuration>
  <system.web>
    <httpHandlers>
      <add verb="GET" path="*.css" validate="false" type="CssHandler" />
    </httpHandlers>
   </system.web>

  <!-- for iis7 integrated pipeline-->
  <system.webServer>
    <handlers>
      <add name="CssHandler" verb="GET" path="*.css" preCondition="integratedMode" type="CssHandler" />
    </handlers>
  </system.webServer>

</configuration>

define a HttpHandler and wire it into iis via web.config, in this case I've got a class named CssHandler that implements the IHttpHandler interface.

<configuration>
  <system.web>
    <httpHandlers>
      <add verb="GET" path="*.css" validate="false" type="CssHandler" />
    </httpHandlers>
   </system.web>

  <!-- for iis7 integrated pipeline-->
  <system.webServer>
    <handlers>
      <add name="CssHandler" verb="GET" path="*.css" preCondition="integratedMode" type="CssHandler" />
    </handlers>
  </system.webServer>

</configuration>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文