Use SignalR in WebApi .Net Core 2? - asp.net-web-api2

I want to use SignalR in a WebApi .Net Core 2 project.
So, I want to install Microsoft.AspNetCore.SignalR package , But I can't find it in www.nuget.org
How can I Use SignalR in a WebApi .Net Core 2 project?

You need to check "Include prerelease":
More details how to use:
https://blogs.msdn.microsoft.com/webdev/2017/09/14/announcing-signalr-for-asp-net-core-2-0/

Related

Azure Pipeline Ambiguous Selection

I've a private repository in my Azure DevOps.
It was a WebAPI built on .NET 6 preview. But when I try to create a Pipeline for this, These are the options DevOps is offering me.
My application is an ASP.NET Core WebAPI. But here it was mentioned:
"Build and Test ASP.NET Projects targeting .NET Framework".
I thought Classic ASP.NET is on .NET Framework and ASP.NET Core is for .NET Core.
Which Pipeline I can use to build my app and why ASP.NET Core has a (.NET Framework) in brackets?
If you click show more you will find:
Until today these templates do not work for modern net 5.0+ apps.
This is what should be done
https://learn.microsoft.com/en-us/azure/devops/pipelines/ecosystems/dotnet-core?view=azure-devops&tabs=dotnetfive

Helper library for ASP.NET Core 5 - NuGet packages not available?

I'm writing a helper library for ASP.NET Core 5 (with .NET 5) and I need some APIs from the package Microsoft.AspNetCore.Server.Kestrel.Core. However, the package is only available in version 2.2 - not version 5.
Is ASP.NET Core no longer distributed via NuGet? And if so, how does one get the APIs with ASP.NET Core 5.
Side note: I found that I could use Microsoft.NET.Sdk.Web as SDK for the project but I'm unsure whether this is a valid/good/correct approach when writing a library.
Is ASP.NET Core no longer distributed via NuGet? And if so, how does one get the APIs with ASP.NET Core 5.
That's correct. The core of ASP.NET Core (no pun intended...) ships with .NET Core >= 3.0 as a shared framework. You can add a single FrameworkReference to your nuget package to pull this in. See https://learn.microsoft.com/en-us/aspnet/core/migration/22-to-30?view=aspnetcore-5.0&tabs=visual-studio#migrate-libraries-via-multi-targeting for more information.
Some background can be found here https://github.com/dotnet/aspnetcore/issues/3756

It's correct reference .NET Core from .NET Framework project?

I have an ASP NET MVC project with net471 target framework but I found nuget reference to Microsoft.AspNetCore.* or Microsoft.EntityFrameworkCore.*
It's correct? What problems can it entail?
It depends. First, I'm not sure if you're using terminology correct. Do you have an ASP.NET MVC 5 project or an ASP.NET Core project? If the former, then yes, it's very much incorrect. If the latter, then no it's fine, depending on the ASP.NET Core version.
.NET Framework 4.7.1 implements .NET Standard 2.0, which .NET Core 2.2 is also compatible with. Therefore, you can include ASP.NET Core 2.2 packages in a .NET Framework 4.7.1 project. Despite the name, an ASP.NET Core web app doesn't have to actually run on .NET Core. However, ASP.NET Core 3.0 or EF Core 3.0 would not work because those depend on .NET Standard 2.1, which no version of .NET Framework implements (and probably never will).

How can I connect to a SignalR hub using ASP.NET Core 2.1

I am trying to connect to SignalR hubs from an ASP.NET Core 2.1 project.
Looking at the documentation here: https://learn.microsoft.com/en-us/aspnet/core/signalr/dotnet-client?view=aspnetcore-2.2, it says a package reference to Microsoft.AspNetCore.SignalR.Client is required.
Looking at the NuGet site (https://www.nuget.org/packages/Microsoft.AspNetCore.SignalR.Client/) for this library, no versions for .NET Core 2.X are available.
How come there are no versions for 2.1 available? What library can I use for connecting to SignalR hubs using .NET Core 2.1, if not Microsoft.AspNetCore.SignalR.Client?
The SignalR version numbers are a bit confusing because SignalR was actually not available with ASP.NET Core 1.x but came later with 2.x. And it shipped on a separate lifecycle which you can also see by the versions of the Microsoft.AspNetCore.SignalR package. So basically, the numbers are just very out of sync with ASP.NET Core versions.
They are fixing that in ASP.NET Core 3, where SignalR and its clients will be regular parts of ASP.NET Core, shipping normally with the framework and sharing version numbers.
For 2.x this basically means that you just pick the latest SignalR 1.x. To verify the best version, you should also look at the dependencies of Microsoft.AspNetCore.SignalR.Core which is the base dependency for both the client as well as the server package. You will see that it also depends on Microsoft.AspNetCore.Authorization. So that should be your indicator which version to use for which version of ASP.NET Core.
To summarize:
For ASP.NET Core 2.1, use version 1.0.4 of the server package and the client package.
For ASP.NET Core 2.2, use version 1.1.0 of the server package and the client package.
For ASP.NET Core 3.0, the server part already ships with ASP.NET Core and for the client use a 3.0 version.
Actually, you will not face any issue using the latest SignalR stable package (#aspnet/signalr#1) with .net core 2.1. Please see the related doc for more info.

Imageresizer and PrettyGifs in asp.net core

In previous versions of ASP.NET Core we used PrettyGifs plugin. In order to make it working we had to add in Web.config. But in asp.net core we don't have web.config anymore. So how can we use this plugin?
All plugins also offer code-based configuration/installation, like new PrettyGifs().Install(Config.Current);
That said, ImageResizer 4.X requires .NET Full for the moment. Imageflow will support .Net Core and is cross-platform.