开发者

How to get IIS 7 to route requests for .css files to aspnet_isapi.dll?

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 开发者_JAVA百科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?


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.


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>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜