在Asp.Net2.0中可以方便的訪問設定檔web.config,如判斷debug設定,驗證類型

來源:互聯網
上載者:User

Asp.Net2.0中我們可以方便的訪問設定檔中,.NetFrameWork2.0新增加了 SystemWebSectionGroup 類。

允許使用者以編程方式訪問設定檔的 system.web 組。

比如判斷web.config內是否為 debug="true",或者判斷身分識別驗證形式

SystemWebSectionGroup ws = new SystemWebSectionGroup();

CompilationSection cp = ws.Compilation;

用cp.Debug;就可以得到compilation節內關於"debug"的配置

AuthenticationSection as = ws.Authentication;

用 as.Mode 可以擷取 authentication節中關於"mode"的配置,值為AuthenticationMode 枚舉之一

AuthenticationMode的取值如下:

成員名稱 說明

Forms 將基於 ASP.NET 表單的身分識別驗證指定為身分識別驗證模式。

None 不指定身分識別驗證。

Passport 將 Microsoft Passport 指定為身分識別驗證模式。

Windows 將 Windows 指定為身分識別驗證模式。在使用 Internet 資訊服務 (IIS) 驗證方法(基本、簡要、整合 Windows (NTLM/Kerberos) 或認證)時適用此模式。

附:SystemWebSectionGroup 類的公用屬性:

名稱 說明 

AnonymousIdentification 擷取 anonymousIdentification 節。

Authentication 擷取 authentication 節。

Authorization 擷取 authorization 節。

BrowserCaps 擷取 browserCaps 節。

ClientTarget 擷取 clientTarget 節。

Compilation 擷取 compilation 節。

CustomErrors 擷取 customErrors 節。

Deployment 擷取 deployment 節。

DeviceFilters 擷取 deviceFilters 節。

Globalization 擷取 globalization 節。

HealthMonitoring 擷取 healthMonitoring 節。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.