web.config 节点
寻找web.config就进查找,当前目录-》上级目录》全局web.config》全局machine.config>还没有返回NULL
<location path="images">
针对指定路径设置配置信息。相当于一个容器。独立的web.config
<authenitication mode="forms">
mode设置身份验证模式。
<compication debug="true" batch="true">
batch 是否全部编译
debug是否进行调试,开发状态。发布时改为false,否则对性能有影响。
<customErrors mode="on">
<error statuCode="403" redirect="403.html">
on表示可以看到自定义信息,跳转到自定错误页面
off 查看源代码错误, 禁止自定义错误信息
<httpHandlers>
<add path="book/*.txt" verb="*" type="">
对指定目录文件动作进行配置,可以设置某个文件夹禁止访问等。
path表示book文件夹下所有.txt文件,verb="*"表示所有类型动作,type表示处理该动作程序。
iis 虚拟目录>配置-映射 配置相应格式文件(.aspx)请求处理程序和允许请求的动作(get\post等)
<httpRuntime maxRequestLength="40960" executionTimeout="180" appRequestQueueLimit="100" >
maxRequestLength="4096":千字节(KB),指定输入流缓冲值限制,默认4096(4M)
executionTimeout="180" :允许执行请求最大秒数
<sesstionState cookiesless="false" mode="inproc" timeout="30">
mode="inproc":默认inproc,由asp.net辅助进程来保持会话状态,不能多个站点共享。
使用sqlServer模式,因为数据库都采用同一个,则可以共享会话状态。
timeout="30":超时时间30分钟。
cookiesless="false":不是用cookies
<globalization fileEncodeing="utf-8" requestEncoding="uft-8" responseEncoding="utf-8">
fileEncodeing:设置.aspx,asmx,asax,文件存储编码
requestEncoding:设置客户请求的编码。
请求编码和响应编码需设置一致,默认设置utf-8,目前支持最多的文字。
<httpModules>
<ad name="ddd" type="mumu.name.module">
name:自定义modules名称,可随意取,不重复即可。
type:指定module的命名空间。
<pages validateRequest="false">
<controls>
<add tagPrefix="" namespace="">
</controls>
</pages>
validateRequest:设置全局是否对请求进行合法性验证,主要对html标签的验证。默认为true;
controls:主要用于配置全局自定义的控件,这样就不用在每个页面中进行配置。
tagPrefix:自定义控件前缀.
namespace:自定义控件命名空间。
<appSettings/>
<add key="upLoadUrl" value="">
读取key节点名字的值value
读取方式:system.ConfigurationManager.AppSetting["upLoadUrl"]
<connectionStrings />
<add name="" connectionString="">
读取name节点的值 connectionString
读取方式:system.ConfigurationManager.ConnectionString["upLoadUrl"].ConnectionString
创建自定义节点和读取:
webconfig中配置该section节点
<section name="AB.UAPConfigSection" type="System.Configuration.NameValueSectionHandler"/>
使用section节点
<AB.UAPConfigSection>
<add key="UAPAddress" value="http://www.baidu.com"/>
<add key="UAPAddress2" value="http://www.google.com/"/>
<add key="UAPApiKey" value="EvMINCYD2XOnV9231eHnlaasdTD0VRGPCpLgTxWz"/>
<add key="UAPAppId" value="32"/>
</AB.UAPConfigSection>
C# 读取该配置节点代码:
System.Collections.Specialized.NameValueCollection MyABsection=new NameValueCollection( );
MyABsection= (NameValueCollection)System.Configuration.ConfigurationManager.GetSection("ND.UAPConfigSection");
string address= MyABsection["UAPAddress"];//取得address="http://www.baidu.com"

浙公网安备 33010602011771号