asp.net提供了3種認證方式: windows身分識別驗證, Forms驗證和Passport驗證.
windows身分識別驗證: IIS根據應用程式的設定執行身分識別驗證.要使用這種驗證方式,在IIS中必須禁用匿名訪問.
Forms驗證:用Cookie來儲存使用者憑證,並將 未經身分識別驗證的使用者重新導向到自訂的登入頁.
Passport驗證:通過Microsoft的集中驗證服務執行的,他為成員網站提供單獨登入 和核心設定檔服務.
一. 配置windows身分識別驗證
1)配置IIS設定
2)設定Web.config
<system.web>
<authentication mode = "Windows">
<!--通知作業系統將當前登入的使用者的信任書傳遞給瀏覽器-->
<authorization>
<!--禁止匿名使用者存取-->
<deny users = "?"/>
</authorization>
</system.web>
二.配置Forms身份認證
1)配置web.config
<?xml version="1.0"?>
<!--
Note: As an alternative to hand editing this file you can use the
web admin tool to configure settings for your application. Use
the Website->Asp.Net Configuration option in Visual Studio.
A full list of settings and comments can be found in
machine.config.comments usually located in
\Windows\Microsoft.Net\Framework\v2.x\Config
-->
<configuration>
<appSettings/>
<connectionStrings/>