1.在web.config文件中有如下配置
1 <configuration> 2 3 <!--数据库链接配置--> 4 <connectionStrings> 5 <add name="ConnectionString" connectionString="Data Source=.;Initial Catalog=QualityCourses;Persist Security Info=True;User ID=sa;Password=sa" 6 providerName="System.Data.SqlClient" /> 7 8 </connectionStrings> 9 10 <!--文件上传配置--> 11 <system.web> 12 <identity impersonate="true" userName="January" password="master0932"/> 13 14 </system.web> 15 16 </configuration>
2.现在在后台代码中获取如上的的配置信息
1 IdentitySection section = (IdentitySection)WebConfigurationManager.GetSection("system.web/identity"); 2 proc.StartInfo.UserName = section.UserName.ToString(); 3 string password = section.Password.ToString();
详细信息请参看