Blake Rivell
Blake Rivell

Reputation: 13875

Realtime notifications in an ASP.NET MVC Core app

I have a bunch of notification records stored in a database with a NotificationDateTime field.

I need to be able to display these notifications to the user in real-time as they become available.

I am assuming I am going to have to constantly ping the server from the client every second to check if there are any notifications available at the current time.

I believe the SignalR library would be perfect for this scenario. However, I don't think it is compatible with ASP.NET Core which is what my application is. Are there any alternative techniques that I could use for something like this.

Upvotes: 1

Views: 3432

Answers (1)

Tseng
Tseng

Reputation: 64180

SignalR is kind of available for ASP.NET Core, but it's itself still in development.

The 0.2.0-rtm-22752 version is the latest one build against ASP.NET Core 1.1 (as seen in it's project.json).

It's not published on the official nuget feed, so you need to add the aspnetcore-master myget feed (link).

Or in VS 2015: Tools > Options... > Nuget Package Manager > [+] Icon.

There add "https://dotnet.myget.org/F/aspnetcore-master/api/v3/index.json" as nuget source.

Then the packages of aspnetcore-master become available via nuget.

For SignalR you don't need to poll the server yourself. SignalR will by default try to connect via Websockets and if that fails, fall back to long polling or keep the connection active by other means.

Upvotes: 3

Related Questions