In this article, we are going to learn how to run a .NET application as a Linux service. Linux operating system contains a service manager called Systemd. The Systemd acts as an initialization system and controls what programs and services run when the system boots up. While working with Linux, we can make use of Systemd to manage our services.
In my previous post I described how to return XML from a minimal API endpoint. In this post I look at an alternative approach, using the open source library, Carter.
In this article, we are going to learn how to create a .NET Core Worker Service and run it as a Windows Service.
Recently I’ve been asked for a sample using EF Core with MySQL. When using EF Core I’m using Micorosft SQL Server or Azure Cosmos DB – and you have many code samples for EF Core in my book Professional C# and .NET, 2021 Edition. To demonstrate using EF Core I took one of the existing samples and changed the SQL Server provider to a MySQL provider. For not needing to install MySQL on my system, I’m using a Docker image as you can read here...
So this blog post comes from doing some work recently to containerize a .Net 4.8 project that needs to run on a Windows container. I wrote about Windows containers already so this is going to be some other tips to help someone who may have run into the same issues I did.
If you've been keeping up with my development content, you'll remember that I recently wrote Build Your First .NET Core Application with MongoDB Atlas, which focused on building a console application that integrated with MongoDB. While there is a fit for MongoDB in console applications, many developers are going to find it more valuable in web applications. In this tutorial, we're going to expand upon the previous and create a RESTful API with endpoints that perform basic create, read, update, and delete (CRUD) operations against MongoDB Atlas.
之前发布过第一个版本,有兴趣的可以去看看:NET Core 基于Quartz的UI可视化操作组件 GZY.Quartz.MUI 简介GitHub开源地址:l2999019/GZY.Quartz.MUI: 基于Quartz的轻量级,注入化的UI组件 (github.com) (欢迎点Start收藏~)总而言之,这个组件主要想做的就是:像swaggerUI一样,项目入侵量小,仅需要在Startup中注入的UI组件目前完成了第二个版本,1.增加本地json持久化调度任务,无需数据库2.增加直接调用本地类方法,无需通过WebAPI接口.本篇主要是介绍一下这两个新增的功能. 正文一.增加本地json...
How do you implement optimistic concurrency in an HTTP API? There are a couple of different ways, regardless of what datastore you’re using in the backend. You can leverage the ETag header in the HTTP Response to return a “version” of the resource that was accessed. When a client then needs to perform some operation on the resource, they send an If-Match header apart of the request with the value being the result of ETag from the initial GET request. Another option is to leverage hypermedia by returning URIs for actions relevant to a resource that include the version apart of the URI. This enables concurrency to be completely transparent and does not require any knowledge from the client.
I’ve run into this issue not only when migrating legacy projects to use async/await in C# .NET, but even just day to day on greenfields projects. The issue I’m talking about involves code that looks like so
In this post, I want to cover one of the more complex concepts I’ve had to handle regarding serialisation; aggregations.
YARP 是微软开源的一个反向代理项目，英文名叫 Yet Another Reverse Proxy 。所谓反向代理最有名的那就是 nginx 了，没错 YARP 也可以用来完成 nginx 的大部分功能，比如根据不一样的域名代理到不一样的后端服务上。既然它可以做反向代理，那么其实也就可以做服务网关了，类似 Ocelot ，当然缺少部分功能，比如限流降级等。Anyway ，今天先来体验一下。运行 YARPYARP 使用起来非常简单，它只是一个类库而已。我们新建一个 ASP.NET Core 的空网站。然后使用 nuget 安装 Yarp.ReverseProxy 。Install-Packag...
I give a lot of talks about performance and in those talks, I tend to emphasize the architectural impact of your choices. There is a huge tendency to focus on micro optimizations to get the performance you need, even though you can usually get orders of magnitude higher performance by making architectural changes.
In this short post I tackle a question I have received several times—"how can I update an ASP.NET Core 5 app that uses Startup to .NET 6's minimal hosting APIs"?
In this post I describe a new feature in C# 10, the [CallerArgumentExpression] attribute, how it can be used to create "throw helpers", and the addition of a throw helper to ArgumentNullException.
It's typical for API endpoints to call application or domain services. In the case of success, the API can simply return Ok and the result of the service call. But for non-success cases, should you use exceptions to communicate from the service to the endpoint, so that it can return an appropriate status code and response? Assuming you read the title of this article, you probably already know the answer I'm going to give. But first let's look at a (bad) example. Consider the following method found in a service that will be called by an API endpoint (controller action)
In the previous post, I described the LoggerMessage source generator that can give performance benefits without the boilerplate. In this post I look at the updates to the source generator API in .NET 6, why the changes were made, and how to update your source generators to use them.
REST API’s often require a PATCH method to partially update resources. A typical scenario for this would be when updating a survey questionnaire type workflow or even, as in the example I will demonstrate, updating a customers shopping cart in an e-commerce Microservice. As a customer updates their cart by adding, removing or editing products in the cart you’ll need to cater for a number of operations.