管理你的asp.net

 

管理你的asp.net

网站一般胡两个服务器组成,

web服务器和配置服务器.

配置文件格式

找回配置文件

使用管理API

使用管理工具

 

ASP.NET 2.0提供了一系列函数用以处理网

站的各种问题,包括对网站的管理

.. 配置管理API

.. 新的配置工具

.. 配置文件加密

 

ASP.NET的配置文件是一个标准的基于文

本的xml文件,名为web.config,可以存在

于网站中的任何目录下

 

在运行asp.net的时候,多个配置文件需要按照一定顺序

调用

. 1. Base configuration settings for machine.

C:/WinNT/Microsoft.NET/Framework/v2.0.xxxxx/config/m

achine.config

. 2. Root web configuration settings for machine.

C:/WinNT/Microsoft.NET/Framework/v2.0.xxxxx/config/w

eb.config

. 3. Overridden by the configuration settings for the

site (or the root application).

C:/inetpub/wwwroot/web.config

. 4. Overridden by application configuration settings.

D:/MyApplication/web.config

. 5. Overridden by subdirectory configuration settings.

D:/MyApplication/MyDir/web.config

 

web.config  ---可以设置为拒绝复写

 

Web.config还可以添加自定义的元素,如下例

<configuration> <configSections> <section

name="mySection"

type="SettingsClasses.MySectionSettings" />

</configSections> <mySection .../>

</configuration>

 

xml文件可以当作全局变量使用.

 

很多ASP.NET内建的配置元素是集合元素

对于集合元素的配置有3种基本标记,分别

<add>,<remove>,<clear>标记

. <configuration> <system.web>

<httpHandlers> 

<add path="*.webservice"verb="GET, POST"type="MyHandlers.WebServiceHandler" />

<remove path="*.asmx" verb="GET,POST" />    --移除.asmx的请求,不处理该类型请求

</httpHandlers> </system.web>   

</configuration>

 

 

在某些情况下,希望首级目录的配置文件不被下

级目录重载,也就是说,首级目录的配置文件不

允许被重写,则可以使用如下配置。

. <configuration> <location path="app1"

allowOverride="false">             ---拒绝该方法重写,如果后面重写会报错.

<system.web>

<sessionState enabled="false" />

</system.web> </location> <location

path="app2" allowOverride="false">

<system.web> <sessionState enabled="false" />

</system.web> </location> </configuration>

 

 

可以在程序设计中使用

CongifurationManager类来实现对配置信息

的访问

 

<configuration> <appSettings> <add

key="currencyService"

value="http://www.microsoft.com/services/curren

cyService.asmx" /> <add

key="creditCardValidationService"

value="http://www.microsoft.com/services/cc.as

mx" /> </appSettings> </configuration>

 

ConfigurationManager.AppSettings("currencySe

rvice")

 

Asp.net 2.0现在提供了一套对web.config进行导航、

读取、写入操作的函数。API有如下好处

把配置信息作为一个强类型暴露给用户,可以方便

的访问

. API提供内建的诸多语法检查机制,保证编写的特

性都正确

方便的在配置信息进行导航

可以对本地和远程的应用进行配置读写

API添加的特性马上可以被管理

 

管理API

WebConfigurationManager.OpenMachineConfiguration()

?2. Open root web.config on the local machine.

WebConfigurationManager.OpenWebConfiguration(null)

?3. Open web.config for the application at the root of the default web

site. WebConfigurationManager.OpenWebConfiguration("/")

?4. Open web.config for a subdirectory of the application found at

/MyApp.

WebConfigurationManager.OpenWebConfiguration("/MyApp/subdir")

?5. Open web.config for an application at the root of another site.

WebConfigurationManager.OpenWebConfiguration("/", "Another Site")

?6. Open the <location> tag for a subdirectory at the application level.

WebConfigurationManager.OpenWebConfiguration("/", null, "/subdir")

?7. Open machine.config on another computer, using credentials

provided. WebConfigurationManager.OpenMachineConfiguration(null,

"remotemachine", "user", "password")

 

配置文件具有多极结构,对它的访问可

以使用Congiguration.GetSection方法

获得配置文件中指定列的值

 

web.config加密

dpapi---web.config在别的机器无法使用,无法做平行移动.

rsa---加密和解密来管理你的web.config

1 Configuration config = Configuration.GetWebConfiguration(Request.ApplicationPath); §@ï/±¨ÖTŸ™bbs.51aspx.com

d'ؑ=@/
2 ConfigurationSection section = config.Sections["connectionStrings"];
§@ï/±¨ÖTŸ™bbs.51aspx.com


d'ؑ=@/
3 section.SectionInformation.ProtectSection("RsaProtectedConfigurationProvider");;
§@ï/±¨ÖT Ÿ™bbs.51aspx.com
d'ؑ=@/

4 config.Update ();

 

 

加密—— pef§@ï/±¨ÖTŸ™bbs.51aspx.com

d'ؑ=@/
C
/.../aspnet_regiis.exe -pef "connectionStrings" "你的Web项目路径" §@ï/±¨ÖTŸ™bbs.51aspx.com


d'ؑ=@/
-prov "DataProtectionConfigurationProvider"
§@ï/±¨ÖT Ÿ™bbs.51aspx.com
d'ؑ=@/

§@ï/±¨ÖT Ÿ™bbs.51aspx.com
d'ؑ=@/

§@ï/±¨ÖT Ÿ™bbs.51aspx.com
d'ؑ=@/

解密 —— pdf §@ï/±¨ÖT Ÿ™bbs.51aspx.com
d'ؑ=@/

/.../ aspnet_regiis.exe -pdf "connectionStrings" "
你的 Web 项目路径 " §@ï/±¨ÖT Ÿ™bbs.51aspx.com
d'ؑ=@/

§@ï/±¨ÖT Ÿ™bbs.51aspx.com
d'ؑ=@/

§@ï/±¨ÖT Ÿ™bbs.51aspx.com
d'ؑ=@/

注意事项 §@ï/±¨ÖT Ÿ™bbs.51aspx.com
d'ؑ=@/

程序读取加密字符串时,不需要编码解密 §@ï/±¨ÖT Ÿ™bbs.51aspx.com
d'ؑ=@/

加密和解密在同一台计算机上使用 §@ï/±¨ÖT Ÿ™bbs.51aspx.com
d'ؑ=@/

中文路径问题 §@ï/±¨ÖT Ÿ™bbs.51aspx.com
d'ؑ=@/

 

 

 

javascript加密

.net中还内嵌了那些加密方法:目前有RSADPAPI

 

Web的管理工具

 

 

getsection方法不加父节点的时候默认是从configuration 

 

 



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值