MSDN Magazine Launch Issue - February 15, 2008 - (Page 52) tool will automatically prompt the user to download the client assembly whenever it is not present on the client already (this currently only works when managing IIS 7.0 on Windows Server 2008 from a Windows Vista SP1, Windows XP, or Windows Server 2003 client by using the remote IIS Manager available online from iis.net/ downloads/?tabid=34&g=6&i=1524). Be sure that you trust both the server you are connected to and the publisher of the IIS Manager extension before accepting this installation, as otherwise it may possibly allow untrusted code to execute on your machine with your user account privileges. After deploying the module and installing the configuration section schema and the IIS Manager extension, the Response Modification feature is ready to use. You can now enable the feature for any of the applications on your server and configure it with any of the IIS 7.0 configuration tools and APIs. In addition, you can use the IIS Manager tool to quickly manage the response modification rules for applications, both on the local server or on a remote server. Using the IIS Manager delegation support, you can even configure which users have the ability to remotely create and manage the response modification rules for specific sites on a server. To demonstrate the Response Modification feature in action, Figure 10 shows how I configured rules for my Qdig image gallery application (featured in msdn.microsoft.com/msdnmag/issues/08/01/ PHPandIIS7). Figure 11 shows how I use the Mvolo.ResponseModification.Filters.RegExReplace filter provided with the Response Modification framework to intelligently insert header and footer content into all pages in the Web site, without modifying the actual source code of the application. The Response Modification module can also be used to easily implement any number of custom content insertions, hyperlink substitutions, and other response modification schemes by implementing replacement filters. These filters can then be deployed globally, or with an application, and configured via configuration rules in the responseModification configuration section. Figure 10 Enabling Headers and Footers <add name=”Header” conditionType= ”Mvolo.ResponseModification.Conditions.ContentTypeCondition” condition=”text/html” replaceType=”Mvolo.ResponseModification.Filters.RegExReplace” replace=” ]*)>” replaceWith=” Welcome to my gallery! ” options=”IgnoreCase” /> <add name=”Footer” conditionType= ”Mvolo.ResponseModification.Conditions.ContentTypeCondition” condition=”text/html” replaceType=”Mvolo.ResponseModification.Filters.RegExReplace” replace=” ” replaceWith=” Copyright mvolo 2007 ” options=”IgnoreCase” /> Tying It All Together Build Your Own Figure 11 Using Response Modification to Modify Responses There are quite a few creative uses for the Response Modification feature whenever it is not possible to achieve the same results by modifying the source code of an application (which is always more efficient than modifying the response on the fly). For example, I also use it to inject a small script into HTML responses that changes image tags to use highly compressed versions of images and then replaces them with higher-quality versions on the fly to provide for a more responsive browsing experience for slow clients. This also uses a custom imaging handler that can provide JPEG images with any desired compression level for a static image using the Microsoft Windows Imaging Component APIs. Figure 11 shows the result in action, including the header, footer, and the low-quality preloaded image (right before it is automatically replaced with the higher resolution version). Modifying responses on the fly can be an expensive mechanism, 52 msdnmagazine IIS 7.0 both in terms of CPU usage and memory requirements as multiple large buffers must be allocated to store transformed versions of the responses. This overhead may or may not be acceptable in production Web sites, depending on the types of response modification filters used, the number of them, and the performance requirements of the application. In order to learn more about using the Response Modification framework, you should download it, along with its source code, from the Response Modification development site (www.mvolo.com/ responsemod). After you understand how response filters work and can plan for using them given performance overhead considerations, look for further samples on the Response Modification development site. To learn more about extending IIS 7.0, be sure to visit iis.net and my blog (mvolo.com), which is dedicated to developing and using IIS 7.0. ■ http://iis.net/downloads/?tabid=34&g=6&i=1524 http://iis.net/downloads/?tabid=34&g=6&i=1524 http://msdn.microsoft.com/msdnmag/issues/08/01/PHPandIIS7 http://msdn.microsoft.com/msdnmag/issues/08/01/PHPandIIS7 http://www.mvolo.com/responsemod http://www.mvolo.com/responsemod http://iis.net http://mvolo.com
For optimal viewing of this digital publication, please enable JavaScript and then refresh the page. If you would like to try to load the digital publication without using Flash Player detection, please click here.