
.net core/.net 5.0 API接口 线程阻塞异常
不能直接在API接口里面用 System.Threading.Thread.Sleep阻塞线程,如果需要延时,要用异步处理。今天碰到这样的一个坑 在win 10 和 windows server 2008 没问题,但在windows server 2019 就出现以下问题An error occurred while processing your request.//错误的写法[Rou…
不能直接在API接口里面用 System.Threading.Thread.Sleep阻塞线程,如果需要延时,要用异步处理。今天碰到这样的一个坑 在win 10 和 windows server 2008 没问题,但在windows server 2019 就出现以下问题An error occurred while processing your request.//错误的写法[Rou…
大致添加内容如下UEditorController控制器代码 public class UEditorController : Controller {private readonly UEditorService _ueditorService;public UEditorController(UEditorService ueditorService){this._ueditorService = ueditorService;}[HttpGet, HttpPost]publi…
在.net core使用GB2312时抛出以下异常 System.ArgumentException:“'gb2312' is not a supported encoding name. For information on defining a custom encoding, see the documentation for the Encoding.RegisterProvider method. 解决方法 在NuGet 添加“System.Text.Enco…
整个 asp.Net Core应用都是在 管道中运行的,管道中放的都是中间件。下面是自定义中间件的两种方法方法一 public class TestMiddleware {//转载请保留 http://www.luofenming.com/show.aspx?id=ART2020021200001private readonly RequestDelegate _next;public TestMiddlewar…
这里我用的是.net Core 3.1 以下是核心代码 public class RefuseStealingMiddleWare {//转载请保留http://www.luofenming.com/show.aspx?id=ART2020021000001private readonly RequestDelegate _next;public RefuseStealingMiddleWare(RequestDelegate next){_next = next;}p…
完整代码链接:https://pan.baidu.com/s/1wjmBtHhVhthNNnDCFU6hKA 提取码:bg51核心代码class OversellTest {//转载请保留http://www.luofenming.com/show.aspx?id=ART2020010500003private static bool IsGoOn = true;//秒杀活动是否结束public static void Show(){using (R…
Redis: REmote DIctionary Server 远程字典(内存)服务器,基于内存管理(数据全部存在内存),实现了多种数据结构的,单线程模型的应用程序,提供插入-查询-固化-集群功能。Redis特点:速度快,数据可能丢失,只能做缓存,而不是存储。以下核心代码(这里采用的是StackExchange)…
结构图Program类代码 public class Program {public static void Main(string[] args){CreateHostBuilder(args).Build().Run();}public static IHostBuilder CreateHostBuilder(string[] args) =>Host.CreateDefaultBuilder(args).ConfigureAppConfiguration(conf =>{conf.Add…
.net Core微服务架构之健康检查和自定义负载均衡策略 以下是框架结构图Nuget下载Consul,服务注册核心代码(写了一个扩展方法) Nuget下载Consul,服务注册核心代码(写了一个扩展方法) public static class ConsuHelper {public static void ConsuRegist(this IConfiguration c…
.net Core微服务架构之集群,服务注册和发现,客户端--多服务实例--Consul完成服务的注册与发现,框架结构图如下Nuget下载Consul,服务注册核心代码(写了一个扩展方法) public static class ConsuHelper {public static void ConsuRegist(this IConfiguration configuration){tr…