Troublesome Microsoft WebSockets Namespaces

So far in textbooks, blogs, and official documentation, I have seen:

  • Microsoft.Web.WebSockets
    • Received from NuGet
    • The assembly is Microsoft.WebSockets, but the namespace is Microsoft.Web.WebSockets
    • Last updated September 14, 2011
    • Contains WebSocketHandler, WebSocketCollections, WebSocketExtensions
  • System.Web.WebSockets
    • Part of .NET 4.5 and is available in Visual Studio 11 Developer Preview
    • Contains the classes AspNetWebSocket, AspNetWebSocketContext, AspNetWebSocketOptions
    • MSDN Documentation
  • System.Net.WebSockets
    • Thanks to Ladislav Mrnka for pointing this out.
    • Part of .NET 4.5 and is available in Visual Studio 11 Developer Preview
    • Contains WebSocket, HttpListenerWebSocketContext and more
    • MSDN Documentation
  • System.ServiceModel.WebSockets
    • I must have guessed that I saw it somewhere, can't find it now
  • Microsoft.ServiceModel.WebSockets
    • Retrieved from html5labs.interoperabilitybridges.com / ....
    • Installed in [Program Files] \ Microsoft SDK \ WCF WebSockets \ 11.06.22 \ bin
    • Contains the classes WebSocketHost, WebSocketService, WebSocketsService, as well as interfaces and collections.
    • Last updated June 22, 2011.

are they somehow different? Are there several older versions?

I always assumed that the Microsoft.Web namespace was used for pre-release code, but even the demos at the Build conference use this namespace, despite the fact that .NET 4.5 includes the System.Web.WebSockets namespace built-in.

System.Web.WebSockets seems to have the same API as Microsoft.Web.WebSockets, but with classes and methods prefixed with AspNet.

System.ServiceModel.WebSockets is part of the WCF namespace, which also seems like a reasonable place to host this stuff.

Help - I'm confused. What should i use?

+43
html5 websocket wcf
Oct 24 '11 at 12:50
source share
5 answers

I will add a little more of your confusion. Microsoft.* Prefix assemblies / namespaces are usually either very specific for any language, or they are not part of the .NET framework (delivered outside the range (or prototypes)).

Assemblies / namespaces shipped with the .NET framework usually start with System.* . There are two namespaces in .NET 4.5 that contain functions related to WebSockets:

  • System.Net.WebSockets - WebSockets implementation
  • System.Web.WebSockets - WebSockets integration with ASP.NET

I do not see System.ServiceModel.WebSockets , but I think there was a prototype named Microsoft.ServiceModel.WebSockets

+23
Oct 24 2018-11-11T00:
source share

html5labs.interoperabilitybridges.com :

... we do not plan any future updates to this prototype.

System.Web.WebSockets :

... namespace contains classes that support the addition of WebSocket functionality for ASP.NET Web Forms applications.

Microsoft.Web.WebSockets:

... provides functionality for writing WebSocket-enabled server applications on Windows 8 using ASP.NET and WCF




My conclusion:

  • System.Net.WebSockets seems to be something low level.
  • System.Web.WebSockets if you are using ASP.NET Web Forms
  • Microsoft.Web.WebSockets from NuGet looks best when you use ASP.NET MVC
+4
Feb 07 2018-12-12T00:
source share

@Greg Woods re System.ServiceModel.WebSockets: you did not represent it.

http://html5labs.interoperabilitybridges.com/media/1165/readme.htm

+1
Jul 30 '12 at 19:47
source share

Regarding Microsoft.Web.WebSockets vs System.Web.WebSockets ...

I think that:

System.Web.WebSockets - gives you the bottom api for working with websites

while...

Microsoft.Web.WebSockets is a kind of higher api, which greatly facilitates the work, and also tries to reflect events / functions that are in the html5 / javascript specification (for example, onerror, onopen, onmessage, onclose, send, etc. )

+1
May 6 '14 at 15:46
source share

This is my belief in why naming Microsoft.Web.WebSockets :

"This preview package provides functionality for writing WebSocket-enabled server applications on Windows 8 using ASP.NET and WCF. Requires .NET 4.5 RC and Windows 8 RC."

Perhaps this is a Microsoft library. * named, because it was developed against Windows 8 RC. Which is not a reliable dependency, so it cannot be part of the official .net framework.

Of course, as soon as Windows 8 comes out, they can depend on it and start releasing websockets libraries as part of the official structure. Thus, Microsoft.Web.WebSockets can be effectively deprecated without leaving the status of preliminary publication.

What about System.Web.WebSockets vs System.Net.WebSockets ?

System.Web.WebSockets: "classes that support the addition of WebSocket functions for ASP.NET Web Forms applications."

Hm ... It seems simple. These classes are intended for use in ASP.NET web forms. Is Windows 8 required? Not sure.

System.Net.WebSockets: this is something else that is not related to web forms. But it only works if you have Windows 8.

Microsoft.ServiceModel.WebSockets

Another old prepayment package. It works on Windows 7!

Note: instead of worrying about what works on the platform + framework to use to get WebSockets, you can simply use SignalR instead, which will select the transport and try to do something like websites for you.

+1
May 28 '14 at 9:58
source share



All Articles