ASP.NET Core has built-in aspsettings.env.json which can automatically apply to different environments. But how about NLog? In official examples, it only got one nlog.config file which will be used in all environments. Let's see how we can change it to use different config files on different environments. Why do we need this This requirement actually came from this blog system. My blog runs on …
Git is the preferred source code version control tool for many programmers, and I've recently switched from TFVC to Git. I am going to show you how to operate Git with .NET Core. Why am I doing this First of all, we do have a lot of good Git clients, such as GitHub for Windows, VS/VS Code, git GUI, and so on, all quite mature, there is no need for us to reinvent this wheel in own. NET/C#. But on …
We developers won't have access to servers all the time, and without management capabilities, it will be difficut to restart a web application. However, in ASP.NET Core, there is a way for us to programmatically restart our application without requring management capabilities from server admins. IApplicationLifetime There is a IApplicationLifetime interface in ASP.NET Core which can handle events …
Yes, you read it right! It's totally possible! Even .NET Core is designed to be cross platform, but it does not mean you can not use platform specific APIs. Take Windows Registry for example, although .NET Standard can not contain Windows API like this. But there's still a way to use Windows Regisitry in .NET Core Applications. But first, you should be absolutely clear, that using platform …
People familiar with the. NET framework knows that we can let the compiler self-increase the version number by specifying AssemblyVersion as 10.0.*. But. NET core and. NET Standard are not. Even with open-source projects like MSBump, there are certain flaws. Typically, such a requirement happens on a CI/CD server. Let's take a look at how to easily handle it with Azure DevOps. About Versioning in …
I met a strange problem recently. After configuring the CI/CD pipeline with Azure DevOps and automatically deploy to Azure App Services, the. NET Core Website failed to start. Let's see how we can solve this problem. Find the issue First of all, fortunately, this is a staging environment. I found that the site unexpectedly did not log anything, even log directory cannot be found, which is very …
There are several methods to determine the language of a given text. In this age of artificial intelligence, we can incorporate AI capabilities into our own applications. In this tutorial, I will demonstrate how to utilize the AI Cognitive Service offered by Microsoft Azure to identify the language of a text. …
Visual Studio has always been a good friend to .NET developers, although VS Code can do .NET Core development, VS is still having a lot advantages. Let's see how to make Visual Studio more handy for .NET Core development. Basic Configuration First, please be advised, not all versions of Visual Studio supports .NET Core development, even some early version of VS2017. Some people may mistake for …
In ASP.NET Core, we can easily use constructor injection to make Dependent Injections on components such as Controller and ViewComponent. But how to do it with ActionFilterAttribute? The Problem My blog system has an ActionFilter for deleting subscription files, and I want to log errors when an exception happens. I use NLog as the logging component, so I need to use LogManager. …
ASP.NET Core provides a built-in Data Protection mechanism to let us encrypt or decrypt sensitive data. There are some limitations that can cause problems while bringing convenience. I met some problems these days.
My Scenario
My blog system has a feature to send email notifications, so you need to configure an email account to let the program use that account to send mail to an administrator …