电竞比分网-中国电竞赛事及体育赛事平台

分享

authentication 元素(ASP.NET 設(shè)置架構(gòu))

 好一則博博則精 2018-01-18
 

[本文檔僅供預(yù)覽,在以后的發(fā)行版中可能會發(fā)生更改。包含的空白主題用作占位符。]

配置 ASP.NET 身份驗證方案,該方案用于識別查看 ASP.NET 應(yīng)用程序的用戶。

<authentication 
   mode="[Windows|Forms|Passport|None]"
> 
   <forms>...</forms>
   <passport/>
</authentication>

以下幾節(jié)描述了特性、子元素和父元素。

特性

特性

說明

mode

必需的特性。

指定應(yīng)用程序的默認(rèn)身份驗證模式。 此特性可以為下列值之一。

Value 說明
Windows 將 Windows 驗證指定為默認(rèn)的身份驗證模式。 將它與以下任意形式的 Microsoft Internet 信息服務(wù) (IIS) 身份驗證結(jié)合起來使用:基本、摘要、集成 Windows 身份驗證 (NTLM/Kerberos) 或證書。 在這種情況下,您的應(yīng)用程序?qū)⑸矸蒡炞C責(zé)任委托給基礎(chǔ) IIS。
Forms 將 ASP.NET 基于窗體的身份驗證指定為默認(rèn)身份驗證模式。
Passport 將 Microsoft Passport Network 身份驗證指定為默認(rèn)身份驗證模式。
None 不指定身份驗證。 您的應(yīng)用程序僅期待匿名用戶,否則它將提供自己的身份驗證。

Windows." xml:space="preserve"> 默認(rèn)值為 Windows。

子元素

元素

說明

forms

配置 ASP.NET 應(yīng)用程序以執(zhí)行基于窗體的自定義身份驗證。

passport

指定要重定向到的頁(如果該頁要求身份驗證,而用戶尚未通過 Microsoft Passport Network 身份驗證注冊)。

父元素

元素

說明

configuration

指定公共語言運行時和 .NET Framework 應(yīng)用程序所使用的每個配置文件中均需要的根元素。

system.web

指定配置文件中 ASP.NET 配置設(shè)置的根元素,并包含用于配置 ASP.NET Web 應(yīng)用程序和控制應(yīng)用程序行為方式的配置元素。

authentication element configures the ASP.NET authentication scheme for an ASP.NET application." xml:space="preserve"> authentication 元素為 ASP.NET 應(yīng)用程序配置 ASP.NET 身份驗證方案。 身份驗證方案確定如何識別要查看 ASP.NET 應(yīng)用程序的用戶。 mode attribute specifies the authentication scheme." xml:space="preserve"> mode 特性指定身份驗證方案。 ASP.NET Authentication." xml:space="preserve">有關(guān)可用的身份驗證方案的更多信息,請參見 ASP.NET Authentication。

默認(rèn)配置

authentication element is not explicitly configured in the Machine.config or the root Web.config file." xml:space="preserve"> Machine.config 或根 Web.config 文件中未顯式配置下面的默認(rèn) authentication 元素。 但它是 .NET Framework 2.0 版中應(yīng)用程序返回的默認(rèn)配置。

<authentication mode="Windows">
   <forms 
      name=".ASPXAUTH" 
      loginUrl="login.aspx" 
      defaultUrl="default.aspx" 
      protection="All" 
      timeout="30" 
      path="/" 
      requireSSL="false" 
      slidingExpiration="true" 
      cookieless="UseDeviceProfile" domain="" 
      enableCrossAppRedirects="false">
      <credentials passwordFormat="SHA1" />
   </forms>
   <passport redirectUrl="internal" />
</authentication>

authentication element is configured in the Machine.config file in the .NET Framework version 1.1." xml:space="preserve">下面的默認(rèn) authentication 元素在 .NET Framework 1.1 版的 Machine.config 文件中配置。

<authentication mode="Windows">
   <forms 
      name=".ASPXAUTH" 
      loginUrl="login.aspx" 
      protection="All"  
      timeout="30" 
      path="/" 
      requireSSL="false" 
      slidingExpiration="true">
      <credentials passwordFormat="SHA1"></credentials>
   </forms>
   <passport redirectUrl="internal" />
</authentication>

authentication element is configured in the Machine.config file in the .NET Framework version 1.0." xml:space="preserve">下面的默認(rèn) authentication 元素在 .NET Framework 1.0 版的 Machine.config 文件中配置。

<authentication mode="Windows">
   <forms 
      name=".ASPXAUTH" 
      loginUrl="login.aspx" 
      protection="All"  
      timeout="30" 
      path="/" >
      <credentials passwordFormat="SHA1"></credentials>
   </forms>
   <passport redirectUrl="internal" />
</authentication>

下面的代碼示例演示如何為基于窗體的身份驗證配置站點、指定傳輸來自客戶端的登錄信息的 Cookie 的名稱以及指定當(dāng)初始身份驗證失敗時使用的登錄頁的名稱。 authorization section to require forms authentication by all users and to deny anonymous users access to the site." xml:space="preserve">必須將 authorization 節(jié)包含在內(nèi)才能要求對所有用戶進行 Forms 身份驗證,并拒絕匿名用戶訪問站點。

<configuration>
   <system.web>
      <authentication mode="Forms">
         <forms name="401kApp" loginUrl="/login.aspx"/>
      </authentication>
      <authorization>
         <deny users="?"/>
      </authorization>
   </system.web>
</configuration>

配置節(jié)處理程序

AuthenticationSection

配置成員

AuthenticationMode

可配置的位置

Machine.config

根級別的 Web.config

應(yīng)用程序級別的 Web.config

要求

Microsoft Internet 信息服務(wù) (IIS) 版本 5.0、5.1 或 6.0

.NET Framework 版本 1.0、1.1 或 2.0

Microsoft Visual Studio 2003 或 Visual Studio 2005

    本站是提供個人知識管理的網(wǎng)絡(luò)存儲空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點。請注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點擊一鍵舉報。
    轉(zhuǎn)藏 分享 獻(xiàn)花(0

    0條評論

    發(fā)表

    請遵守用戶 評論公約

    類似文章 更多