第七章 配置文件与网站部署
? ? ? ? ? ? ? ? ? ? ? ? ? ?第七章 ? ?配置文件與網站部署
1.配置文件管理:
? ? ? ?(1).配置文件:①machine.config(有且只有一個)
? ? ? ? ? ? ? ? ? ? ②web.config(每個站點都有一個web.config)
? ? ? ?(2)配置連接字符串:
? ? ? ? ? ?<connectionString>
? ? ? ? ? ? ? ?<add name="配置名" connectionString="server=.;database="數據庫名";uid=sa;pwd=123456;"/>
? ? ? ? ? ?</connectionString>
? ? ? ? ? ?<appsettings>
? ? ? ? ? ? ? ?<add key="xxx" value="xxx"/>
? ? ? ? ? ?<appsettings>
? ? ? ?(3)使用連接字符串:
? ? ? ?private ?static string connectionString = configurationManager.connectionString["配置名"].ToString();
? ? ? ?(4)數據庫連接字符串的加密和解密:(vs命令提示)(加密和解密必須在同一機上完成)
? ? ? 加密: aspnet_regiis.exe ?-pef section physical_directory -prov provider
? ? ? ? ? ? 或者
? ? ? ? ? ? aspnet_regiis.exe ?-app section physical_directory -prov provider
? ? ? 解密:aspnet_regiis.exe ?-pdf section physical_directory -prov provider
2.自定義錯誤的配置
? ? ? ?<system.web>
? ? ? ? ? ?<customErrors mode="on" defaultRedirect="">
? ? ? ? ? ? ? ?<error statusCode="404" redirect=""/>
? ? ? ? ? ? ? ?<error statusCode="403" ?redirect=""/>
? ? ? ? ? ?</customErrors>
? ? ? ? </system.web>
? ? ? ?defaultRedirect:指定發生錯誤時,瀏覽器重定向到頁面的url
? ? ? ?mode:指定自定義錯誤的狀態,on表示啟用,off表示禁用,remoteonly表示其顯示給遠程計算機.
? ? ? ?statusCode:http的狀態碼,404表示未找到資源,403表示禁止訪問.
? ? ? ?redirect:指定當前錯誤發生時,重定向到頁面的url.
3.身份驗證和授權配置:
? ?(1)身份驗證:windows驗證
? ? ? ? ? ? ? ?forms驗證
? ? ? ? ? ? ? ?passport驗證
? ? ? ? ? ? ? ?<system.web>
? ? ? ? ? ? ? ? ? ?<authentication ?mode="windows">
? ? ? ? ? ? ? ? ? ?<authentication ?mode="Forms">
? ? ? ? ? ? ? ? ? ? ? ?<forms name="user" loginUrl="" timeout="60"></forms>
? ? ? ? ? ? ? ? ? ?</authentication>
? ? ? ? ? ? ? ? ?<authentication ?mode="passport">
? ? ? ? ? ? ? ?</system.web>
? ?(2)授權
? ? ? ?<!
<?xml version="1.0"><configuration><system.web><authorization><!--禁止匿名用戶--><deny users="?"/><!--允許管理員角色--><allow roles="admin"/></authorzation></system.web></configuration>轉載于:https://blog.51cto.com/7112081/1343378
總結
以上是生活随笔為你收集整理的第七章 配置文件与网站部署的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 怎么快速高效的排课?
- 下一篇: 小脑萎缩和帕金森症状上有什么相同?