Edi Wang

.NET and Azure Developer

.NET

Run ASP.NET Core Websites with Windows Server Core on Azure

Microsoft Azure provides App Service that is fully managed to enable you to run websites. However, in some cases, you may still need an IaaS solution like a VM to host your website. This article will show you how to run an ASP.NET Core 2.2 web application on a Windows Server 2019 Datacenter Server Core virtual machine hosted in Azure. About Windows Server Core Windows was designed as an operating …
.NET Windows Azure

About Per Monitor-DPI aware for WinForms Applications

WinForms is the traditional .NET desktop application workload running on Windows. For historical reasons, there are some problems with its support for high DPI and for different DPI screens, and this article explores the possible solutions. Windows "96" PPI history The default DPI for Windows systems (more precisely called PPI) is 96. PPI means pixel per inch, which means how many pixels are …
.NET WinForm DPI

Build a Simple Matrix Card in .NET

A Matrix Card is typically used in online games for authentication. I built a simple version of a Matrix Card in .NET Core today, let's check it out. How Matrix Card Works This is a typical Matrix Card for the game "World of Warcraft". It has a serial number to bind to the owner's game account, and then use the numbers in the table for validation. Suppose the hacker already knows your account …
.NET Matrix Card

Building a .NET Core URL Forward Service

I recently built a URL forward service named “Link Forwarder” using .NET Core 2.2. It’s open source and currently having a preview version deployed to my subdomain “go.edi.wang”. This article will share how I built it and what I learned. To help you understand the system and walk through the code, please check my GitHub repository for this project: https://github.com/EdiWang/LinkForwarder The …
.NET URL

IP Rate Limit for ASP.NET Core

In websites or API applications, we often want to block high-frequency requests in a short period of time for an IP to prevent boring people or malicious attacks. In ASP.NET Core, limiting the request rate of IP is now super easy, let's see. AspNetCoreRateLimit There's already a nice library for limiting request rate, called AspNetCoreRateLimit. GitHub: https://github.com/stefanprodan/ …
.NET ASP.NET IP

Reset Azure Blob Storage Content Type in .NET Core

My blog is using Azure Blob Storage to store images for posts, however, it went wrong these days when I am trying out Azure CDN, the cause is all my images requests are returning incorrect content-type. Let's see how to reset content type for files in Azure Blob Storage via .NET Core. When I uploaded images using the Azure Storage API for .NET, by default, without setting ContentType, which is …
.NET Azure Azure Blob Storage

Stop Generating Designer.cs for .resx files in .NET Core

In Visual Studio, if we add a Resource File (.resx) to a .NET Core project, you will find a ".Designer.cs" file is automatically generated and updated whenever the resource content changes. This file basically contains auto-generated code for accessing resource values by key. In my blog system, I use the Resource File to maintain the default configuration data when setting up the blog for the …
.NET Visual Studio

How to Pack a .NET Core Class Library and Upload to NuGet

NuGet is the package manager of the. NET world, we can both use official website nuget.org, or build our own corporate and private servers. Now, with . NET Core, it's easier than ever to pack and upload a NuGet package, let's take a look! NuGet Account If you want your package to be used by every .NET developers in the world, then you need to have a nuget.org account to upload your own package.  …
.NET NuGet

Send Email in .NET Core via MailKit

The ability to send e-mail notifications is common in a variety of systems. My blog can also send emails to administrators when there are new comments, new replies, or when articles are referenced by other sites. So in. NET Core, how can we send an e-mail? My case will use Microsoft Outlook.com's personal account to send e-mail, using the SMTP protocol. But you can also do it with other SMTP- …
.NET Email MailKit SMTP

Use Environment Specific nlog.config in ASP.NET Core

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 …
.NET NLog