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

推荐订阅源

酷 壳 – CoolShell
酷 壳 – CoolShell
H
Hacker News: Front Page
P
Palo Alto Networks Blog
T
ThreatConnect
Apple Machine Learning Research
Apple Machine Learning Research
博客园_首页
T
True Tiger Recordings
P
Privacy & Cybersecurity Law Blog
B
Blog
IT之家
IT之家
Last Week in AI
Last Week in AI
F
Full Disclosure
Hacker News: Ask HN
Hacker News: Ask HN
C
Comments on: Blog
Microsoft Azure Blog
Microsoft Azure Blog
C
Cybersecurity and Infrastructure Security Agency CISA
Microsoft Security Blog
Microsoft Security Blog
博客园 - 【当耐特】
N
News and Events Feed by Topic
NISL@THU
NISL@THU
腾讯CDC
雷峰网
雷峰网
Security Latest
Security Latest
李成银的技术随笔
M
Microsoft Research Blog - Microsoft Research
L
LangChain Blog
L
Lohrmann on Cybersecurity
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
C
Check Point Blog
Y
Y Combinator Blog
Recent Announcements
Recent Announcements
博客园 - Franky
N
News | PayPal Newsroom
V
V2EX
A
About on SuperTechFans
The Register - Security
The Register - Security
月光博客
月光博客
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Google Online Security Blog
Google Online Security Blog
MyScale Blog
MyScale Blog
Cisco Talos Blog
Cisco Talos Blog
Vercel News
Vercel News
WordPress大学
WordPress大学
C
Cyber Attacks, Cyber Crime and Cyber Security
The Hacker News
The Hacker News
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
爱范儿
爱范儿
A
Arctic Wolf
L
LINUX DO - 最新话题
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More

博客园 - Laeb

ASP.NET Web 页面语法概览 ASP.NET Web 页面中的新事物 - Laeb 渐增的许可 介绍 ASP.NET Web 页面 - Laeb 管理工具 - Laeb ASP.NET Web 页面概览 检测何时需要更改安全策略 安全策略管理的概览 异常处理的最佳习惯 面向世界应用程序开发的最佳习惯 - Laeb 使用 ASP.NET 所创建的 XML Web 服务的设计指南 为并发执行而创建应用程序与组件的指南 ASP.NET 控件与可访问 ASP.NET 中的可访问支持 实践:创建自定义 HTTP 模块 - Laeb HTTP 模块介绍 实践:创建 HTTP 处理器工厂 - Laeb 实践:注册 HTTP 处理器 - Laeb 实践:创建同步 HTTP 处理器 - Laeb
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 的凭证时的职责而提供援助。

posted on 2007-03-31 21:23  Laeb  阅读(564)  评论()    收藏  举报