随笔分类 - .NET
摘要:前言 在C#中使用HttpWebRequest发起HTTP请求时,达到最大并发和性能可以从以下几个方面改进: 1、ServicePointManager设置 ServicePointManager 类是一个静态类,它提供了用于管理HTTP连接的属性和方法。为了提升并发性能,你需要调整以下几个关键属性
阅读全文
摘要:方案一 asp.net mvc默认的json序列化ValueProviderFactory使用的是javascriptserializer,可以在配置文件web.config中设置: <add key="aspnet:MaxJsonDeserializerMembers" value="150000
阅读全文
摘要:如 public class Person { public string Name{get;set;} public int Age{get;set;} } public class Student : Person { public string Grade {get;set;} [Newton
阅读全文
摘要:using StackExchange.Redis; using System; using System.Configuration; using System.Linq; using System.Threading; using System.Threading.Tasks; namespac
阅读全文
摘要:.NET在Windows Server环境让IIS上支持高并发前言1、调整IIS应用程序池配置2、调整IIS的appConcurrentRequestLimit设置3、调整machine.config中的processModel > requestQueueLimit的设置4、修改注册表,调整IIS
阅读全文
摘要:Swagger原理 Swagger就是利用反射技术遍历所有Api接口,并且从xml文件中读取注释,在利用Swagger内置的模板组合html显示至客户端实现接口可视化,并且可调用。 在WEB Api中,引入了面向切面编程(AOP)的思想,在某些特定的位置可以插入特定的Filter进行过程拦截处理。引
阅读全文
摘要:nuget 安装Swashbuckle 安装完成后会在App_Start中生成SwaggerConfig.cs 项目右键属性生成xml文件 在SwaggerConfig中的Register中进行配置 //在内部的GlobalConfiguration.Configuration.EnableSwag
阅读全文
摘要://.net 4.0 设置: ServicePointManager.SecurityProtocol = (SecurityProtocolType)3072; //.net 4.5 设置: ServicePointManager.SecurityProtocol = SecurityProtoc
阅读全文
摘要:public static void ExportExcelFile(DevExpress.Xpf.Grid.TableView tableView) { if (tableView == null) { MessageBox.Show("导出失败!", "错误提示", MessageBoxButt
阅读全文
摘要:1、foreach遍历列表或数组时,如果list或数组为null,就会报错,如下图: 2、不知道微软封装foreach的为什么不先检查要遍历的对象是否为null,这样就导致,我们在写代码时,遍历列表时就要先判断列表是否为null,如下图: 3、为了简化这一判断是否null的过程,我写了一个扩展方法,
阅读全文
摘要:protected override void OnPaint(PaintEventArgs e) { base.OnPaint (e); FontFamily fontFamily = new FontFamily("Times New Roman"); Font font = new Font(
阅读全文
摘要:bitPhoto.Save(Response.OutputStream, ImageFormat.Jpeg); 图像保存的问题,默认的质量是60% EncoderParameter p; EncoderParameters ps; ps = new EncoderParameters(1); p =
阅读全文
摘要:Introduction# When WPF application launched, it could take a while for a current language runtime (CLR) to initialize .NET Framework. As a result, fir
阅读全文
摘要:简单的岁数计算 DateTime now = DateTime.Today; int age = now.Year - bday.Year; if (bday > now.AddYears(-age)) age--; /// <summary> /// 计算日期的间隔(静态类) /// </summ
阅读全文
摘要:概况 启动不带参数线程的方法 启动带参数线程的方法 线程更新UI 线程锁同步共享数据 启动不带参数线程的方法 第一种快速启动 1 2 3 4 Thread t = new Thread(()=>{ //下面写一些在线程中处理的方法 }); t.Start(); 第二种启动方法 1 2 3 4 5 6
阅读全文
摘要:using System; using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; using abc = Iner; namespace Test { class Program
阅读全文
摘要:线程与异步的使用方法 使用场景 方法 AAA, BBB, CCC 在主线程不阻塞的情况下运行不同的三个方法 方法CCC需要在方法AAA完成后执行 使用线程完成 因为方法 CCC 要等待方法 AAA 完成,所以需要一个线程同步事件。 using System; using System.Threadi
阅读全文
摘要:PetaPoco.Core.ttinclude <#@ template language="C#" hostspecific="True" #> <#@ output extension=".cs" #> <#@ assembly name="EnvDTE" #> <#@ assembly nam
阅读全文
摘要:Dictionary<string, object> suggestions = JSONSerializer.Deserialize<Dictionary<string, object>>(jsonStudent) if (suggestions.Keys.Contains("UserId")){
阅读全文
摘要:不加解释,自己研究 using Org.BouncyCastle.Asn1; using Org.BouncyCastle.Asn1.Pkcs; using Org.BouncyCastle.Asn1.X509; using Org.BouncyCastle.Crypto; using Org.Bo
阅读全文

浙公网安备 33010602011771号