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

推荐订阅源

奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
aimingoo的专栏
aimingoo的专栏
IT之家
IT之家
N
Netflix TechBlog - Medium
MyScale Blog
MyScale Blog
雷峰网
雷峰网
T
Tailwind CSS Blog
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
T
The Blog of Author Tim Ferriss
S
Schneier on Security
C
CERT Recently Published Vulnerability Notes
Help Net Security
Help Net Security
云风的 BLOG
云风的 BLOG
GbyAI
GbyAI
I
InfoQ
H
Help Net Security
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
酷 壳 – CoolShell
酷 壳 – CoolShell
G
GRAHAM CLULEY
Blog — PlanetScale
Blog — PlanetScale
G
Google Developers Blog
I
Intezer
大猫的无限游戏
大猫的无限游戏
AWS News Blog
AWS News Blog
Recent Announcements
Recent Announcements
Google DeepMind News
Google DeepMind News
Spread Privacy
Spread Privacy
博客园_首页
宝玉的分享
宝玉的分享
量子位
T
Threatpost
D
Darknet – Hacking Tools, Hacker News & Cyber Security
Security Latest
Security Latest
C
Cybersecurity and Infrastructure Security Agency CISA
SecWiki News
SecWiki News
H
Hackread – Cybersecurity News, Data Breaches, AI and More
博客园 - Franky
C
CXSECURITY Database RSS Feed - CXSecurity.com
T
The Exploit Database - CXSecurity.com
T
Tenable Blog
Know Your Adversary
Know Your Adversary
P
Proofpoint News Feed
The Register - Security
The Register - Security
V2EX - 技术
V2EX - 技术
Recent Commits to openclaw:main
Recent Commits to openclaw:main
Last Week in AI
Last Week in AI
L
LangChain Blog
T
Tor Project blog
Stack Overflow Blog
Stack Overflow Blog
月光博客
月光博客

博客园 - 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 的凭证时的职责而提供援助。