Using WebSockets in a C# Web Application?

前端 未结 5 1060
甜味超标
甜味超标 2021-02-02 14:40

I know its possible to use WebSockets within C# using a console application running along side the web application but Im wondering if its possible to use the requests on the C#

5条回答
  •  -上瘾入骨i
    2021-02-02 15:34

    It's possible to host a WebSockets server within the context of an ASP.NET. However, you'll need to be aware that the ASP.NET application can be restarted which means the server will be shut down and will need to be re-established along with the ASP.NET application.

    Hosting the WebSockets application within a separate Windows Service would provide greater reliability in the socket server, but then will require IPC to share data between the ASP.NET application and the Windows Service.

    So, there's a trade-off to discuss. It depends on how sensitive your client code is to connection loss and re-establishment. If this is handled sufficiently then hosting within ASP.NET will be fine.

    Note that while WebSockets are new to HTML, the concept has existed for many years with Flash and Java Applets. Especially with Flash it's commonly used for online games and web-based chat.

提交回复
热议问题