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

推荐订阅源

Forbes - Security
Forbes - Security
T
Tailwind CSS Blog
Hugging Face - Blog
Hugging Face - Blog
Blog — PlanetScale
Blog — PlanetScale
WordPress大学
WordPress大学
aimingoo的专栏
aimingoo的专栏
Y
Y Combinator Blog
U
Unit 42
I
InfoQ
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
V
Visual Studio Blog
B
Blog RSS Feed
Vercel News
Vercel News
F
Fortinet All Blogs
Know Your Adversary
Know Your Adversary
T
Troy Hunt's Blog
博客园 - 【当耐特】
MongoDB | Blog
MongoDB | Blog
大猫的无限游戏
大猫的无限游戏
A
About on SuperTechFans
Jina AI
Jina AI
小众软件
小众软件
T
Threatpost
有赞技术团队
有赞技术团队
人人都是产品经理
人人都是产品经理
The Hacker News
The Hacker News
T
The Exploit Database - CXSecurity.com
C
CXSECURITY Database RSS Feed - CXSecurity.com
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Microsoft Azure Blog
Microsoft Azure Blog
Recent Announcements
Recent Announcements
酷 壳 – CoolShell
酷 壳 – CoolShell
Scott Helme
Scott Helme
B
Blog
腾讯CDC
Last Week in AI
Last Week in AI
P
Proofpoint News Feed
S
Schneier on Security
N
News and Events Feed by Topic
Microsoft Security Blog
Microsoft Security Blog
K
Kaspersky official blog
G
Google Developers Blog
T
Tor Project blog
PCI Perspectives
PCI Perspectives
S
Secure Thoughts
Google Online Security Blog
Google Online Security Blog
Latest news
Latest news
Google DeepMind News
Google DeepMind News
MyScale Blog
MyScale Blog
罗磊的独立博客

博客园 - 数码幽灵

[转贴] 网络硬盘“G宝盘”使用体验 - 数码幽灵 - 博客园 个人拼图 有关Web项目使用EnterpriseLibrary的Sercurity问题 - 数码幽灵 - 博客园 关于使用VS.Net2003调试器出现的问题及相关解决方法 关于JavaScript一次提交多个Form出现的问题 看到关于Zope的一些东西 关于SmartClient 与 游戏开发的一点想法 关于Alex 的 ProcessContext 今天看到AppForge的产品 Base4.Net 即将推出 V1.0 WS-Security学习 使用Base4.Net进行项目开发中的问题 发现了C-Omega Essential ASP.NET 读书笔记--WebForm Essential ASP.NET 读书笔记--基础 Visual Studio 2005 Express Download Test Driven C# 读书笔记(下) Test Driven C# 读书笔记(上) 每个.Net开发者现在应该下载的十个必备工具!
Essential ASP.NET 读书笔记--Configuration
数码幽灵 · 2004-07-10 · via 博客园 - 数码幽灵

Asp.Net中使用Config文件是有层次关系的,就是常说的Web.Config文件;
对于放在不同虚拟目录下的Config文件的作用域是不一样的;就如下图所示:

这样做优点是:可以为特殊配置的页面生成特殊的配置,当进行目录变更时把目录进行拷贝就可以;
            缺点是:一旦站点配置出现问题,需要对每个层次下的配置逐一检查;
对这样的层次模型举个例子:

对WebConfig做的更改将会再下一个httprequest到来的时候生效;
但是需要注意的是

这将导致SessionState和ApplicationState的丢失
一个常见的问题是我们要如何保护我们的Web.Config文件?幸运的是asp.net内建了HttpForbiddenHandler来实现对特定文件的限制访问(如.Config,

.cs

,

.vb

,

.asax

,

.resx等

),当试图访问这些扩展名的文件时 ,这个Handler将被调用,返回http error,达到了默认情况下外部客户端是无法访问config文件的目的

特殊的配置元素processModel:
特殊在以下几点:
         仅允许使用在系统范围的machine.config文件中
          改变这个元素后在工作线程重启前不会有任何效果
          其他的配置元素都被托管构件所使用,只有这个是被一个非托管外部模块aspnet_isapi.dll所读取

Attribute

Values

Default

Description

Enable

true | false

true

Whether ASP.NET is hosted in an external worker process (true) or directly in inetinfo.exe (false)

timeout

Infinite | HH:MM:SS

Infinite

Total life of a process梡rocess bounced after timeout

idleTimeout

Infinite | HH:MM:SS

Infinite

Total idle life of a process梡rocess bounced when reached

shutdownTimeout

Infinite | HH:MM:SS

0:00:05

Time given to process to shut down before being killed

requestLimit

Infinite | number

Infinite

Total number of requests to serve before bouncing process

requestQueueLimit

Infinite | number

5000

Number of queued requests allowed before bouncing process

restartQueueLimit

Infinite | number

10

Number of requests kept in queue while process is restarting

memoryLimit

Number

60

Percentage of physical memory process is allowed to use before bouncing process

webGarden

true | false

false

Whether process should be affinitized with a particular CPU (for multi-CPU machines)

cpuMask

Bitmask

0xffffffff

Controls number of CPUs available for ASP.NET worker processes (webGarden must be true)

userName

SYSTEM | MACHINE | username

MACHINE

Windows identity to run the worker process in (MACHINE uses low-privileged ASPNET account)

Password

AutoGenerate | password

AutoGenerate

Password for username

logLevel

All | None | Errors

Errors

Event types logged to event log

clientConnectedCheck

HH:MM:SS

0:00:05

Time a request is left in the queue before a client-connected check is performed

comAuthenticationLevel

Default | None | Connect | Call | Pkt | PktIntegrity | PktPrivacy

Connect

Level of authentication for DCOM security

comImpersonationLevel

Default | Anonymous | Identify | Impersonate | Delegate

Impersonate

Authentication level for COM security

responseRestartDeadlockInterval

Infinite | HH:MM:SS

00:09:00

Time to wait between restarting worker process because of responseRestartDeadlockInterval

responseDeadlockInterval

Infinite | HH:MM:SS

00:03:00

For deadlock detection, timeout for responses when there are queued requests

maxWorkerThreads

Number

25

Maximum number of I/O threads per CPU in the thread pool

maxIoThreads

Number

25

Maximum number of I/O threads per CPU in the thread pool

serverErrorMessageFile

File name

""

Customization for "Server Unavailable" message

读取配置文件:
使用以下代码,可以方便的读取每个除ProcessModel之外的元素中的配置


而静态索引器ConfigurationSettings.AppSettings["xxx"]就是对以上方法的一个方便的包装;

理论上说.Net的Config文件被分为两部分:configuration section handlers和configuration data

一个自定义Section Handler的例子:

首先,自己的配置Xml文件:

然后是对应的一个保存数据的映射类:

然后,实现自己的读取相应格式配置的Handler,实现一个接口IConfigurationSectionHandler:

当然,如果不原意实现自己的Handler的话,也可以使用和AppSettings相同的策略来读取配置,但是必须使用
<add>元素来标记配置;实际上就是一个键值对,配置文件如下:

相应使用的方法如下: