管理你的ASP.NET应用

配置文件web.config
    网站由两个服务器组成(不算后台数据库服务器)。一个是WEB服务器(负责HTML),一个叫应用服务器(负责动态请求,接受请求并返回HTML)。IIS包括了这两种服务器的功能。
  ASP.NET提供了一整套方法进行网站的管理
  1。方便部署。配置文件和网站在同一个地方,复制粘贴即可。
  2。配置文件是一个XML文件,可以用脚本编辑器去编写,也可以用XML可视化工具进行配置。
  3。提供了一套完整的API,可以在程序中进行配置文件的访问和修改(API也可以访问远程的计算机)。
  4。提供了扩展服务,开发者可以提供一些自己的片段
  5。提供了加密机制

访问应用配置
<configration><appSettings><add key = "..." value = "..."/>
Dim Service As String = configurationManager.AppSettings("currencyService");

<configuration><connectionStrings><add name="northwind" connectionString="..." providerName="..."/>...
Dim connection As SqlConnection = New SqlConnection(ConfigurationManager.ConnectionStrings("northwind").Value);

使用管理的API(应用程序接口):
 API的好处:
 把配置信息作为一个强类型暴露给用户,可以方便的访问
 API提供内建的诸多语法检查机制,保证编写的特性都正确
 方便的在配置信息进行导航
 可以对本地和远程的应用进行配置读写
 用API添加的特性马上可以被管理
 
加密配置文件
 对于敏感信息asp.net 2.0支持加密。
 RSA算法加密:
  Dim config As System.Configuration.Configuration = WebConfigurationManager.OpenWebConfiguration(path)
  Dim appSettins As ConfigurationSection = config.GetSection("appSettings")
  if(appSettings.SectionInformation.IsProtected) appSettings.SectionInformation.UnProtectSection();  //如果加密则解密
  else appSettings.SectionInformation.ProtectSection("DataProtectionConfigurationProvider")
  config.Save()
  
使用管理工具(3种):
 MMC控制台,实现了对asp.net的版本控制
 Web的管理工具
 命令行的管理工具

原文地址:https://www.cnblogs.com/vipcjob/p/1540593.html