Can .NET intercept and change css files?

前端 未结 7 477
渐次进展
渐次进展 2021-01-11 11:42

UPDATE 1:

I have now setup IIS6 so .NET can handle calls to .css files. What do I have to do now to get it to change css files based on the referal

7条回答
  •  鱼传尺愫
    2021-01-11 12:24

    I wouldn't recommend using httpModule as it will be called upon for each and every request which might deteriorate performance. Whereas, you can use httpHandlers to handle only specific paths. Therefore, my vote would be to use httpHandlers.

    But there is a glitch. By default, IIS 6 does not pass requests for non ASP.Net extension (read extensions other than .aspx, .ashx, .axd and all that) to ASP.Net by default.

    Therefore, you need to add ISAPI module for CSS extension to pass the request to aspnet_isapi.dll (you can find the complete path from .aspx extension handler).

    This link might help in setting up ISAPI module.

    Once ASP.Net has started handling .CSS extension, write a httpHandler with your logic and add the following line under httphandlers section in web.config file

    Say your httpHandler is CSSHttpHandler then the code would be something like this.

    
    

    Hope this helps.

提交回复
热议问题