let today = new Beginning();

.NET Core

Limit ASP.NET Core request frequency by IP address

By default, the user can request an ASP.NET Core web server unlimitedly. The user may request our web server very frequently and submit lots of spam data. Also, too frequent requests may be a terrible attack which may cost our service down and lots of money. So how can we group the requests by their IP address, limit the frequency of the user requests, and return an error message? There's …


How to run async method in C# synchronous method

In some situations, we may need to run an async method and get its result. But we can't access the await keyword. In the constructor method. When you are implementing an interface sync method. When you are implementing an abstract class sync method. I got a solution to unwrap the async method and call it in the synchronous method. First, put the following code anywhere you like: using …

C# .NET Core Async

Consolidate all Entity-Framework database migrations to one migration

Why do we need to do that? In case you ruined your code or you have too many migrations and caused your editor slow, you may want to reset all migrations. However, deleting all migrations directly in your code will cause database update fail. So I will talk about my solution about how to consolidate all migrations without deleting any data. The following steps only suitable for code-first EF …

ASP.NET Core C# .NET Core Entity Framework SQL Server

Upgrade existing class library to .NET Core 3.0

When we are upgrading our existing class library to the latest .NET Core, like this: <TargetFramework>netcoreapp3.0</TargetFramework> On doing so, you may get the following warning: C:\Program Files\dotnet\sdk\3.0.000\Sdks\Microsoft.NET.Sdk\targetsMicrosoft.NET.Sdk.DefaultItems.targets(149,5): warning NETSDK1080: A PackageReference to Microsoft.AspNetCore.App is not necessary …

C# class library .NET Core