How to install WebSocket Protocol support in IIS using PowerShell's Install-WindowsFeature cmdlet. Easily install and enable support for the WebSocket protocol on Windows Server IIS.

Install Web-WebSockets feature with PowerShell to enable WebSocket support

About WebSocket:

One of the limitations to HTTP is that it was designed as a one-directional method of communication. However, many modern web-based applications require more real-time, two-way communications in order to function optimally. With the release of Windows Server 2012 and Windows 8, Internet Information Services (IIS) 8.0 has added support for the WebSocket Protocol.

The WebSocket Protocol is an open standard that is defined in RFC 6455, and developers can use this functionality to create applications that implement two-way communications over the Internet between a client and server.

You can use the following PowerShell command to easily install the Web-WebSockets feature in IIS:

PS C:\Users\UserName> Install-WindowsFeature -name Web-WebSockets

A second way to install the Web-WebSockets feature in IIS, is to use the Deployment Image Servicing and Management (DISM) command. Enable the Web-WebSockets feature:

%SystemRoot%\system32\dism.exe /online /enable-feature /featurename:IIS-WebSockets

Or use PowerShell's Enable-WindowsOptionalFeature cmdlet as a third option:

Enable-WindowsOptionalFeature -Online -NoRestart -FeatureName IIS-Websockets

You can read how to install IIS on Windows 11 in my post Install IIS in Windows 11 using PowerShell. Don't forget to enable WebSocket support for your website.

Enable .NET 4.5 Windows Communication Foundation (WCF) in IIS 8

In addition, it is recommended to install and enable Windows Communication Foundation (WCF) web services in IIS 8, with .NET 4.5.

You then need to install the HTTP Activation feature:

PS C:\Users\UserName> Install-WindowsFeature -name NET-HTTP-Activation
PS C:\Users\UserName> Install-WindowsFeature -name NET-WCF-HTTP-Activation45

Instead of PowerShell, you can use DISM for this too (of course ;-) ).

"Server Error in MultipleBindings Application" Windows Communication Foundation error

When you've installed the IIS features NET-HTTP-Activation and NET-WCF-HTTP-Activation45, but you receive the following Server Error:

This collection already contains an address with scheme http. There can be at most one address per scheme in this collection.

Then you may have forgotten to enable multipleSiteBindingsEnabled in your web.config file. Or when that freaking .NET web service returns a TypeLoadException like:

TypeLoadException: Could not load type 'System.ServiceModel.Activation. HttpModule' from assembly 'System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'

Then you'll need to add a *.svc handler if the IIS web server feature installation failed to do so.

Donate a cup of coffee
Donate a cup of coffee

Thank you very much! <3 ❤️

1 Comment

Leave a Reply

Your email address will not be published. Required fields are marked *