let today = new Beginning();


ASP.NET Core Integration Test using MSTest

In the official document, there is only an example of the ASP.NET Core integration test using xunit. But what if you don't like xunit? Can we replace that with MSTest? Yes. We can. Brief steps Uninstall xunit. Install MSTest instead. First, clear the project structure. Install MSTest for your test project. Start your …

ASP.NET Core C# .NET Core Test MSTest Functional Test Integration Test

Fire and forget in ASP.NET Core with dependency alive

C# fire and forget might not be suitable in ASP.NET Core To fire and forget in C#, it is really simple: Task.Run(() => FireAway()); But the same approach might not be suitable in ASP.NET Core Controller. Consider the following example: public class MyController : Controller { private readonly MyHeavyDependency _hd; public MyController(MyHeavyDependency hd) { _hd …

ASP.NET Core C# Async Fire and forget

Creating a proxy to another URL with ASP.NET Core

This post talks about writing a simple HTTP proxy logic in C# or ASP.NET Core. And allowing your project to proxy the request to any other URL. It is not about deploying a proxy server for your ASP.NET Core project. Before starting, you need to be clear about the target you are going to proxy for. It shall be an URL. Add the following code anywhere of your project. public static …

ASP.NET Core Reverse Proxy Web Proxy

EF second layer cache to enhance your SQL database performance based on Redis

Entity-Framework Core is a lightweight, extensible, open-source, and cross-platform version of the popular Entity Framework data access technology. It really helps the developer to build applications which access database easily. But in most cases, we may cache some results which do not change frequently, to reduce access to our database. For example, the home page of a blog may not change …

ASP.NET Core C# SQL Server SQL Entity Framework Core Azure Redis Caching

Microsoft account integrated sign in via C#

This code example indicates how to build an app that supports Microsoft account OAuth authentication. Before coding, we gonna create an app in your Azure portal first. The name is your app's display name. Select your app can access accounts in any organization and personal Microsoft account. As for the redirect URI, it must be your server redirect back address. For …

ASP.NET Core Azure Microsoft OAuth Login Authentication

Share view component between different ASP.NET Core web project

When some logic in C# can be shared between projects, we gonna create a new class library project. But sometimes we just want to share some view components. For example, for all pages in Aiursoft, it all contains a Logout component. Writing this more than one time doesn't make sense. So how can we share it? First, we gonna create a new .NET Core class library project alongside it. Name it: …

ASP.NET Core C# class library View component

Support multi-tenant in pure Entity Framework Core

Multi-tenant requires many features because the data can be separated by different tenants. So when you are accessing the database, you don't need to worry that your operation will affect other tenants. Multi-tenancy is the ASP.NET boilerplate's most important feature and works perfectly with Domain-driven design. But how can we implement the multitenant feature with only pure Entity Framework …

ASP.NET Core C# Entity Framework Multi-tenant

Auto update database for ASP.NET Core with Entity Framework

If your ASP.NET Core project is connecting to your database via entity framework, you can't be unfamiliar with the script: dotnet ef database update. Without executing the script your database is not the latest and this may cause some issues. Traditionally we update the database every time we start our app or publish our app. But we may forget this process and it costs us work. How can we …

ASP.NET Core C# Entity Framework SQL Server

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 …


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

Using IIS and web.config to support large file upload

When you try and upload a large file (over the size limit in IIS) you will see an error message that looks something like: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. By default, IIS web server allows for limited file size to be uploaded to the web …

IIS web.config ASP.NET ASP.NET Core

  • 1