随笔分类 - C#
摘要:
## 前言: 上一篇分分享了[基于阿里云实现的短信验证码](https://www.cnblogs.com/wml-it/p/17613232.html)文章,考虑到为了防止登录时,非人工操作,频繁获取验证码,趁热打铁,现在添加了图片验证码服务功能。借鉴网上传统的做法,把实现这两个验证的功能做成有个
阅读全文

摘要:
## 前言: 阿里云短信服务是一项基于云计算和大数据技术的企业级短信平台服务。它能够为企业和开发者提供高可用、高性能、高稳定性的短信发送服务,可以快速地将各类业务通知、验证码、营销推广等信息发送给用户。在我们经常登录一些系统或者APP时候,经常会遇到其他登录登录方式——短信验证码登录。这也是我前一段
阅读全文

摘要:## 一、什么是过滤器? ### 过滤器定义: 过滤器与中间件很相似,**过滤器(Filters)**可在**管道(pipeline)**特定阶段(particular stage)前或后执行操作,可以将过滤器视为**拦截器(interceptors)**。在.NET MVC开发中,权限验证是非
阅读全文
摘要:## 一、什么是中间件? 中间件是一种装配到应用管道以处理请求和响应的软件。是介于request与response处理过程之间的一个插件(一道处理过程),相对比较轻量级,并且在全局上会影响到request对象和response对象的属性。因为改变的是全局,所以需要谨慎实用,用不好会影响到性能。每个组
阅读全文
摘要:### 1.读取JSON配置文件 ```C# /// /// 获取配置文件 /// /// public static List GetConfigs(string configName) { var filePath = string.Concat(AppContext.BaseDirectory
阅读全文
摘要:using System; using System.IO; using System.Text.RegularExpressions; using System.Threading; using Newtonsoft.Json; using Newtonsoft.Json.Linq; namesp
阅读全文
摘要:POST请求 public static string HttpPost(string url, string data) { string address = url; HttpWebRequest request = (HttpWebRequest)WebRequest.Create(addre
阅读全文
摘要:/// <summary> /// JsonConvertHelper /// </summary> public class JsonConvertHelper { /// <summary> /// 将对象序列化为JSON格式 /// </summary> /// <param name="o"
阅读全文
摘要:本文技术方案支持.Net/.Net Core/.Net Framework 数据分页,几乎是任何应用系统的必备功能。但当数据量较大时,分页操作的效率就会变得很低。大数据量分页时,一个操作耗时5秒、10秒、甚至更长时间都是有可能的,但这在用户使用的角度是不可接受的…… 数据分页往往有三种常用方案。 第
阅读全文
摘要:关键代码如下 public partial class Form1 : Form { private static string filePath=""; private static string directory = ""; private static string watchpath =
阅读全文
摘要:要求不少于8位且至少包含字母及数字 string regexStr = "^(?![0-9]+$)(?![a-zA-Z]+$)(?!([^(0-9a-zA-Z)]|[\\(\\)])+$)([^(0-9a-zA-Z)]|[\\(\\)]|[a-zA-Z]|[0-9]){8,}$"; if (!Sys
阅读全文
摘要:写入 /// <summary> /// 创建写入xml /// </summary> /// <param name="path"></param> /// <param name="filename"></param> private static void CreateXmlFile( str
阅读全文
摘要:1、使用Math.Round方法处理 double a = 3.1415926; //使用四色五入保留2位小数 double b = Math.Round(a,3); Console.WriteLine(b); //输出:3.142 2、使用 decimal.Round方法处理 double a =
阅读全文
摘要:一、抽象基类BaseAttribute /// <summary> /// BaseAttribute 的摘要说明 /// </summary> public abstract class BaseAttribute : Attribute { public abstract string Vali
阅读全文
摘要:三种读取文件的方法: 1、全部读取 #region 全部读取到字符串变量 string text = System.IO.File.ReadAllText(@"E:\TestPath\Test.txt"); System.Console.WriteLine("Contents of Test.txt
阅读全文
摘要:NuGet 安装 Serilog 核心的包是 Serilog 和 Serilog.AspNetCore 建议安装 Serilog.AspNetCore,几乎包含了Serilog常用的所有包 异步写入 Serilog.Sinks.Async 写入MSSQL Serilog.Sinks.MSSqlSer
阅读全文
摘要:#.NET支持的类型参数约束有以下五种: where T : struct | T必须是一个结构类型 where T : class | T必须是一个Class类型 where T : new() | T必须要有一个无参构造函数 where T : NameOfBaseClass | T必须继承名为
阅读全文
摘要://序列化对象 static byte[] Serialize(MyObject obj) { //二进制序列化 IFormatter formatter = new BinaryFormatter(); using (MemoryStream ms=new MemoryStream ()) { f
阅读全文
摘要:public class VerifyCode { /// <summary> /// 生成验证码 /// </summary> /// <returns></returns> public byte[] GetVerifyCode() { int num = 80; int num2 = 30;
阅读全文
摘要:class CountdownEventTest { const int numIterations = 10; static CountdownEvent latch1 = new CountdownEvent(1); static void Main() { #region 方式一 //Thre
阅读全文