ASP.NET中的應用程式配置
來源:互聯網
上載者:User
asp.net|程式 ASP.NET配置使用層次式配置體繫結構。ASP.NET的所有配置資訊都包含了在設定檔中,該檔案為config.web,它位於與應用程式檔案相同的目錄中。除非子目錄內的config.web檔案覆蓋了父目錄的設定,否則,子目錄降繼承父目錄的設定。
config.web檔案為每種主要的ASP.NET功能提供了對應部分。
config.web檔案中有關安全的內容如下所示:
<security>
<authentication mode=”[windows/cookie/passport/none]”>
<cookie cookie=”[name]” loginurl=”[url]” decryptionkey=”[key]”>
<credentials passwordformat =”[clear,shal,md5]”>
<user name=”[username]”password=”[password]”/>
</credentials>
</cookie>
<passport redirecturl=”internal”/>
</authentication>
<authorization>
<allow users=”[comma separated list of users]” roles=”[comma separated list of roles]”/>
<deny users=”[comma separated list of users]” roles=”[comma separated list of roles]”/>
</authentication>
<identity>
<impersonation enable =”[true/false]”/>
</identity>
</security>
這部分主要分為三部分:
»認證
»授權
»身份
通過應用程式根目錄的應用程式設定檔中類似的一部分來覆蓋電腦層次設定檔中的對應部分,就可以設定每個要素的值。所有子目錄降自動繼承設定,然而,子目錄也可以通過覆蓋其父目錄的設定來擁有自己的設定檔。