Differences between "Microsoft.Extensions.Caching.Redis" and "Microsoft.Extensions.Caching.StackExchangeRedis.Redis"? - asp.net-core

I am a little bit lost. I am reading Microsoft documentation for ASP.NET Core caching using Redis.
And the documentation suggests to use Microsoft.Extensions.Caching.StackExchangeRedis which is an open source third party library.
But I've seen some other tutorials are using Microsoft.Extensions.Caching.Redis, which is a more native asp.net core.
And at the end they both use the same interface IDistributedCache.
Why do I need Microsoft.Extensions.Caching.StackExchangeRedis?
What advantages it has over Microsoft.Extensions.Caching.Redis?

A look at the dependency graph for Microsoft.Extensions.Caching.Redis and Microsoft.Extensions.Caching.StackExchangeRedis reveals it.
Microsoft.Extensions.Caching.Redis is based on StackExchange redis 1.x library, whereas Microsoft.Extensions.Caching.StackExchangeRedis is based on 2.x of the same library.
Also Microsoft.Extensions.Caching.Redis doesn't seem to target the 3.1 extension libraries (Microsoft.Extensions.Options/Caching.Abstractions) where the other does.
So for .NET Core 3.x and newer use Microsoft.Extensions.Caching.StackExchangeRedis as the previous one may not be maintained as long as the new one.

Related

ASP.NET Core Web Application with .NET Framework, I want to switch the target to .NET Core

I'm trying to change ASP.NET Core web application with .NET Framework as a target framework to use .NET Core 3.1.X
I try changing the target framework in the project file (.csproj), I encounter dependency issues, dependency conflict....
Is there any straightforward method to solve this issue?
Before you start your migration, you should know there’s several difference between .net framework and .net core, so please follow the official document to do some Pre-Migration steps.
Then you can follow this official document to migrate your application from framework to .net core 3.1.
Since your ideal .net core version is 3.1, still I suggest you can try to use .net 6. Also, you can use this upgrade tool to reach your goal. In fact, using this upgrade assistant is a batter choice than you doing it by yourself. Even if you are insisting using .net core 3.1, you can use this assistant to upgrade your version to 6 first then change it to 3.1.
Note:
Before you start your migration, please make a backup of your original project. That's because some packages in .net framework may be no longer available in .net core. So if there're some errors occur, you can go back to the original one.

ASP.NET Core ConfigurationProvider from database

I wonder if there is implemented ConfigurationProvider for ASP.NET Core which loads options from Database. EF or Dapper.
It's fairly easy to implement ourselves, but I wonder if there is ready solution, and if this really a good idea.
According to your description, I suggest you could try to use EfConfigurationProvider, you could directly use by installing through nuget package.
Install-Package EfConfigurationProvider -Version 0.2.1
More details about how to use it ,you could refer to this article.
If this doesn't match your requirement, I suggest you could create the custom provider by yourself, like this blog shows.

Where are the nuget authentication packages for aspnet core 3?

I have a custom authentication component that is working with net core 2.2. I've started migrating the project to net core 3, but it seems like MS hasn't updated the authentication Nuget packages.
Until now, I was referencing the Microsoft.AspNetCore.Authentication package. The package still exists, but hasn't been updated to net core 3.0 (it's still on the 2.2 version).
I can't keep using it because net core 3.0 has moved the RequestPathBaseCookieBuilder type to a different namespace (so, at runtime, I'll get a tyoe loading exception). A quick search shows that only the Microsoft.AspNetCore.Authentication.OpenIdConnect has been updated to net core 3.0 (and if I add it to my project, then my component to work without any issues).
Anyone knows why MS hasn't still updated the other security nuget packages to version 3? Is there anyway to solve this without using the openidconnect nuget package (I'm only using it because it was the first that was updated and it will bring the correct Microsoft.AspNetCore.Authentication assembly that I need for my project)?
Looks like I was 10 minutes too late, but you posted the answer as a comment, rather than an answer, and I like questions having answers so I stop opening them when browsing the question search results.
Anyway, as you discovered, .NET Core 3.0 no longer uses packages for base class libraries (BCLs). Instead, they're just part of the SDK, so by targeting netcoreapp3.0 or netstandard2.1, all BCLs are just available. This should eliminate a lot of problems that earlier .NET Core projects had, particularly when referencing .NET Standard 1.x assemblies from netcoreapp2.x tfms. Although the largest benefit will be when all referenced packages target netstandard2.1 or netcoreapp3.0 or above.
Ok, so finally got it. The solution is to use the FrameworkReference element with the Microsoft.AspNetCore.App meta package.

Is dotnet-passbook compatible with .net core?

I have a task to save a ticket in Apple Wallet. for this I found dotnet-passbook
does this for us. Is it compatible with .net core as well?
No. At the bottom of the project Github page the developer clearly states:
.Net Core
I've had several people ask whether this library will
support .Net Core. If I get the time, I'll try and make this a .Net
Standard library, but I'm dependant on Crypto libs etc., so I'll need
to evaluate them to ensure they will work .Net Core also.

Mixing ASP.NET Core with older .Net Framework code

I have some legacy .NET code that I would like to wrap with an API.
The code is a mixture of ASP.NET Webforms and .NET Framework 4.0
I'm hoping to use the new ASP.NET Core Web API and have created a new solution based on this framework and added the legacy code as existing projects.
Everything builds OK but when I try and call some of the legacy code I get the following error:
System.TypeInitializationException occurred HResult=0x80131534
Message=The type initializer for 'TreeManager' threw an exception.
Source=
Inner Exception 1: FileNotFoundException: Could not load file or
assembly 'System.Web.Extensions, Version=4.0.0.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35'. The system cannot find the file
specified.
This is the code I call:
TreeManager.LoadEvent += LoadTree;
public class TreeManager
{
...
public static event EventHandler<LoadEventArgs> LoadEvent;
...
}
I tried updating the legacy code to .NET 4.5.2 but get the same error.
I wrapped the legacy code with an API using ASP.NET MVC 4 API 2 and all worked well.
Is it possible to do this and, if so, what changes do I need to make?
First, you can choose to target either .NET Core or the full framework with a ASP.NET Core app. Just because it's "Core" doesn't mean you have to use .NET Core with it. If you're utilizing legacy APIs, you may be forced to run on the full framework.
If you need or simply want to use .NET Core, so that the app can be deployed outside of a Windows environment, then you'll need to migrate any APIs that aren't supported to alternative APIs or potentially rewrite functionality if no alternative API exists.
.NET Core 2.0 supports .NET Standard 2.0, which has a very large API footprint. Because of this, Microsoft opened up compatibility with legacy .NET Framework libraries and packages. However, no guarantees are made that you can fully utilize those libraries and packages. Just because you can add the dependency doesn't mean you can utilize all the APIs. That's likely what you're running into here. This particular set of APIs has a dependency on System.Web, which is not a part of .NET Core.
Recently, Microsoft has released some tools to make migration scenarios like this easier. First, there's the .NET API Analyzer, a NuGet package which will add Intellisense callouts to API calls that are not compatible with various targets. This will help you track down code that needs to be changed, and alert you when you're writing new code, that you need to do things in a different way than you might be used to.
Second, there's the Windows Compatibility Pack for .NET Core, another NuGet package that shims in support for a lot of older Windows-only APIs from the full framework. This can give you a bit of breathing room during your migration, reducing the amount if things you need to change, somewhat. Though, you are still encouraged to switch out this code eventually as well, eventually weaning your application off of the dependency altogether.
Finally, if none of this helps, you may simply have to find an alternative. That might require installing a third-party NuGet and rewriting some code to work with that instead of what you were using before.
No one ever claimed migrating was easy; it's always an uphill battle. If you don't have the bandwidth to do it now, simply target the full framework and call it a day. Otherwise, dig in and tackle it as best you can.