1

Recently I talked with some developers, and they said that they call one endpoint from their front-end (web app) and that endpoint is a web socket. All their REST calls go through this connection. This solution was in Java. So I started wondering how they do that. How they dispatch the endpoint, what is the payload, etc. but in Asp.NET Core.

I am wondering is it possible and how.

3 Answers 3

1

I see this is very interesting topic. I found this useful- https://developer.okta.com/blog/2019/11/21/csharp-websockets-tutorial

0

You can do this in dotnet core using SignalR: https://learn.microsoft.com/en-us/aspnet/core/signalr/introduction?view=aspnetcore-5.0

2
  • but how about without it.
    – Wasyster
    Commented Apr 17, 2021 at 14:18
  • Why would you want to implement websockets in dotnet core without using a library (SignalR) that makes it a lot easier? If you want to understand how it works then read through the source code: github.com/dotnet/aspnetcore/tree/main/src/SignalR
    – jGroot
    Commented Apr 17, 2021 at 14:37
0

I think you're mixing two different technologies.

A REST endpoint belongs to WebServices and is an url, pointing to one or more methods in your code that can accept parameters and return results in XML/JSON format.

You can then fetch this url from your front-end and read the response.

An example of REST webservice is Google Maps API.

A Websocket, instead, is a continuous connection and works as a plain socket but between a webpage running on a client and another server application on another machine (i.e. the server). It's used when you need an open tunnel with continuous exchange of data: chats, video and audio streaming, multiplayer games and more.

You cannot make a REST call to a websocket endpoint and if you want to use websockets you must write a server in C# (i use .net core). A console application.

I'm unsure what you are looking for exactly. If you want to start with websockets, this is where i started from:

Writing websocket server Writing a websocket server in C#

For webservices:

Writing a web service in ASP.NET

2
  • 1
    Am not mixing it. I am curious how did they do it in java, can we do it in .net core and how!
    – Wasyster
    Commented Apr 17, 2021 at 14:39
  • Of course, we can do that in .net too. Have a look to the links!
    – Davide C
    Commented Apr 17, 2021 at 14:41

Not the answer you're looking for? Browse other questions tagged or ask your own question.