,,,,,,,,,,,,,,第七章,,配置文件与网站部署
1。配置文件管理:
,,,(1)。配置文件:①machine.config(有且只有一个)
,,,,,,,,,,②web . config(每个站点都有一个web . config)
,,,,(2)配置连接字符串:
,,,,,,& lt; connectionString>
,,,,,,,,& lt;添加名称="配置名“connectionString="数据库服务器=?"数据库名“uid=sa; pwd=123456;“/祝辞
,,,,,,& lt;/connectionString>
,,,,,,& lt; appsettings>
,,,,,,,,& lt;添加键=" xxx " value=" https://www.yisu.com/zixun/xxx "/祝辞
,,,,,,& lt; appsettings>
,,,,(3)使用连接字符串:
,,,,私人静态字符串connectionString=configurationManager.connectionString[“配置名”].ToString ();
,,,,(4)数据库连接字符串的加密和解密:(vs命令提示)(加密和解密必须在同一机上完成)
,,,加密:aspnet_regiis。exe, pef部分physical_directory prov提供者
,,,,,,或者
,,,,,,aspnet_regiis。exe,应用部分physical_directory prov提供者
,,,解密:aspnet_regiis。exe, pdf部分physical_directory prov提供者
2。自定义错误的配置
,,,,& lt; system.web>
,,,,,,& lt; customErrors模式=薄癲efaultRedirect="在
,,,,,,,,& lt;错误statusCode=" 404 "="/重定向的在
,,,,,,,,& lt;错误statusCode=" 403 ",重定向="/祝辞
,,,,,,& lt;/customErrors>
,,,,& lt;/system.web>
,,,,defaultRedirect:指定发生错误时,浏览器重定向到页面的url
,,,,模式:指定自定义错误的状态,在表示启用,下表示禁用,remoteonly表示其显示给远程计算机。
,,,,statusCode: http的状态码,404表示未找到资源,403表示禁止访问。
,,,,重定向:指定当前错误发生时,重定向到页面的url。
3。身份验证和授权配置:
,,(1)身份验证:windows验证
,,,,,,,,形式验证
,,,,,,,,护照验证
,,,,,,,,& lt; system.web>
,,,,,,,,,身份验证,& lt;模式=皐indows”在
,,,,,,,,,身份验证,& lt;模式=靶问健痹?/p>
,,,,,,,,,,,,& lt;形式name="用户" loginUrl="超时=" 60 "祝辞& lt;/forms>
,,,,,,,,,,& lt;/authentication>
,,,,,,,,身份验证,& lt;模式=盎ふ铡痹?/p>
,,,,,,,,& lt;/system.web>
,,(2)授权
,,,,& lt; !
& lt; ?xml version=" 1.0 "比; & lt; configuration> & lt; system.web> & lt; authorization> & lt; !——禁止匿名用户——比; & lt;否认用户=" ? "/比; & lt; !——允许管理员角色——比; & lt;允许角色=癮dmin”/比; & lt;/authorzation> & lt;/system.web> & lt;/configuration>