How can I turn on DynamicCompression feature of IIS programmatically?

Posted by LockeVN on Stack Overflow See other posts from Stack Overflow or by LockeVN
Published on 2010-03-05T04:54:40Z Indexed on 2010/03/08 3:51 UTC
Read the original article Hit count: 452

I'm making an installer program for my web application. My web application uses CSS and JS heavily, so I want to enable both Static and Dynamic HttpCompression for IIS7/7.5.

It needs 2 steps:

  1. I can modified the web.config, put <httpcompression> tag, it's ok.
  2. DynamicContentCompression must be turned on in Windows Feature to make httpCompression work.

Static HttpCompression is enable by default in IIS7 and IIS7.5, but Dynamic HttpCompression is not enable by default (although it's available). I can do manually by turn on: Start/ControlPanel/ProgramsAndFeatures/TurnWindowsFeatures on or Off/IIS/WWW Service/Performance features/Dynamic Content Compression, but How can I programmatically turn it on that Windows Feature? I can use PowerShell, C# in my installer.

Any idea how I might be able to do this? Thanks.

© Stack Overflow or respective owner

Related posts about windows-7

Related posts about iis-7.5