How to work with WebSocket[TCP connection] in asp.net web form using c#

Ashok Kumar 221 Reputation points
2022-12-22T09:15:36.183+00:00

I hope this is not a bad question rising but I want to learn this concept with good example then only I can start my Realtime work.

I'm new to this WebSocket[TCP connection] concept and I have read some ( this and this) content regarding this concept I got bit basic knowledge on this but my query is I'm unable to find the sample example tutorial on this concept(in asp.net web form using c#) that is how to create websocket(server side) and how to receive that data(from client side) basic communication between server side and client side.

Please suggest me how to work with websocket and give me basic example.

I'm very beginner in programming language.

Developer technologies ASP.NET Other
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Lan Huang-MSFT 30,186 Reputation points Microsoft External Staff
    2022-12-23T05:50:12.537+00:00

    Hi @Ashok Kumar ,
    You could try hosting a WebSockets server in an ASP.NET context or use SignalR.
    Hope the following document can help you.

    WebSockets in ASP.NET and JavaScript
    Using WebSocket in .NET 4.5
    https://github.com/dotnet/aspnetcore/blob/6cc9f6f130af4ed0e7f321b144265cfbcec0ceee/src/Middleware/WebSockets/samples/AutobahnTestAppAspNet4/EchoSocket.ashx.cs
    SignalR and WebSocket
    https://learn.microsoft.com/en-us/aspnet/signalr/overview/getting-started/introduction-to-signalr#signalr-and-websocket
    Best regards,
    Lan Huang


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.