惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

有赞技术团队
有赞技术团队
MyScale Blog
MyScale Blog
Cyberwarzone
Cyberwarzone
Schneier on Security
Schneier on Security
I
Intezer
Cisco Talos Blog
Cisco Talos Blog
Cloudbric
Cloudbric
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
NISL@THU
NISL@THU
博客园 - Franky
F
Fortinet All Blogs
Google DeepMind News
Google DeepMind News
Jina AI
Jina AI
T
The Exploit Database - CXSecurity.com
P
Proofpoint News Feed
N
News and Events Feed by Topic
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
F
Full Disclosure
T
Troy Hunt's Blog
D
Darknet – Hacking Tools, Hacker News & Cyber Security
Project Zero
Project Zero
P
Palo Alto Networks Blog
Recorded Future
Recorded Future
美团技术团队
D
Docker
PCI Perspectives
PCI Perspectives
Microsoft Azure Blog
Microsoft Azure Blog
MongoDB | Blog
MongoDB | Blog
L
LINUX DO - 最新话题
Recent Announcements
Recent Announcements
Hacker News: Ask HN
Hacker News: Ask HN
人人都是产品经理
人人都是产品经理
月光博客
月光博客
D
DataBreaches.Net
The Hacker News
The Hacker News
爱范儿
爱范儿
V
Visual Studio Blog
Engineering at Meta
Engineering at Meta
SecWiki News
SecWiki News
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
A
About on SuperTechFans
Latest news
Latest news
GbyAI
GbyAI
T
Tor Project blog
L
LINUX DO - 热门话题
Security Latest
Security Latest
博客园 - 聂微东
Y
Y Combinator Blog
AI
AI
M
MIT News - Artificial intelligence

博客园 - Laeb

ASP.NET Web 页面语法概览 ASP.NET Web 页面中的新事物 渐增的许可 介绍 ASP.NET Web 页面 管理工具 ASP.NET Web 页面概览 检测何时需要更改安全策略 安全策略管理的概览 异常处理的最佳习惯 面向世界应用程序开发的最佳习惯 使用 ASP.NET 所创建的 XML Web 服务的设计指南 为并发执行而创建应用程序与组件的指南 ASP.NET 控件与可访问 ASP.NET 中的可访问支持 实践:创建自定义 HTTP 模块 HTTP 模块介绍 实践:创建 HTTP 处理器工厂 实践:注册 HTTP 处理器 实践:创建同步 HTTP 处理器
System.Net 类的最佳习惯
Laeb · 2007-03-31 · via 博客园 - Laeb

下列建议将帮助你使用包含在 System.Net 中的类并且得到它们的最佳优势:

  • 尽可能地使用 WebRequest 与 WebResponse 来代替对于其派生类型的转换。使用 WebRequest 与 WebResponse 的应用程序可以得到新的 Internet 协议的优势,并且代码不需要有太大的变化。
  • 在编写运行在服务器中并且使用 System.Net 中的类的 ASP.NET 应用程序的时候,从性能立场来看,最好是使用异步的 GetResponse 与 GetResponseStream 方法。
  • 被打开的对于 Internet 资源的连接数量会严重影响网络性能与吞吐量。System.Net 默认时会为所托管的每个应用程序使用两个连接。在 ServicePoint 中为你的应用程序设置 ConnectionLimit 属性可以增加特定的托管量。设置 ServicePointManager.DefaultPersistentConnectionLimit 属性可以增加所有的默认托管量。
  • 在编写套接字级别的协议时,尽可能地尝试使用 TCPClient 或者 UDPClient 来代替直接编写 Socket。这两个客户端类封装了 TCP 与 UDP 套接字的创新,并且不需要你处理连接的细节。
  • 在访问需要凭证的站点的时候,使用 CreadentialCache 类来创建凭证缓存要胜于在每个请求中的支持。CredentialCache 类会搜索缓存来查找适当的凭证来呈现一个请求,可以为你创建并且呈现基于 URL 的凭证时的职责而提供援助。