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:
web.config
, put <httpcompression>
tag, it's ok. 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.
This is the way I would have done it:
dism /online /enable-feature /featurename:IIS-HttpCompressionDynamic
dism allows you to check the return code of command, allowing you to verify that it worked (or was already installed)
These PowerShell commands will add add the Dynamic Compression feature.
Import-Module ServerManager
Add-WindowsFeature Web-Server, Web-Dyn-Compression
Don't forget to Run As Administrator or have administrator rights.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With