deviceFilters 項目 (ASP.NET 設定結構描述)

根據使用者代理或瀏覽器指定 ASP.NET MobileCapabilities 系統中的裝置或裝置類別。 裝置篩選條件可以由頁面或應用程式開發人員用以覆寫控制項屬性,或者可用來定義內容區域或樣板以變更配置和外觀。

<deviceFilters>
     <filter.../>
</deviceFilters>

屬性和項目

下列各節將說明屬性、子項目和父項目。

屬性

無。

子項目

項目

描述

filter

選擇性項目。

提供 MobileCapabilities 類別的篩選功能。 <deviceFilters> 區段中可以有一或多個篩選條件項目。

父項目

項目

描述

configuration

Common Language Runtime 和 .NET Framework 應用程式所使用之每個組態檔中的必要根項目。

system.web

針對組態檔中的 ASP.NET 組態設定指定根項目。 包含設定 ASP.NET Web 應用程式和控制該應用程式之行為方式的項目。

備註

您可從兩種類型的裝置篩選條件 (比較評估工具或評估工具委派) 中選取。

對於簡單的比較,可指定以比較為基礎的篩選條件,方法是提供功能名稱和要比較的值。 在執行階段,如果功能值和提供的值相等,則裝置篩選條件會評估為 true。 布林值屬性比較時不區分大小寫;因此 true 和 True 同樣有效。 其他屬性的比較是區分大小寫的。

對於較複雜的評估,可指定以評估工具委派為基礎的篩選條件,方法是提供方法的類別和方法名稱。 在執行階段,會呼叫所提供的方法來決定裝置篩選條件是否評估為 true。

預設的組態

下列預設 <deviceFilters> 項目沒有在電腦組態檔或根目錄 Web.config 檔中明確設定,但它卻是 .NET Framework 2.0 版中應用程式所傳回的預設組態。

<deviceFilters>
    <filter name="isJPhone" compare="Type" argument="J-Phone"/>
    <filter name="isHTML32" compare="PreferredRenderingType" argument="html32"/>
    <filter name="isWML11" compare="PreferredRenderingType" argument="wml11"/>
    <filter name="isCHTML10" compare="PreferredRenderingType" argument="chtml10"/>
    <filter name="isGoAmerica" compare="Browser" argument="Go.Web"/>
    <filter name="isMME" compare="Browser" argument="Microsoft Mobile Explorer"/>
    <filter name="isMyPalm" compare="Browser" argument="MyPalm"/>
    <filter name="isPocketIE" compare="Browser" argument="Pocket IE"/>
    <filter name="isUP3x" compare="Type" argument="Phone.com 3.x Browser"/>
    <filter name="isUP4x" compare="Type" argument="Phone.com 4.x Browser"/>
    <filter name="isEricssonR380" compare="Type" argument="Ericsson R380"/>
    <filter name="isNokia7110" compare="Type" argument="Nokia 7110"/>
    <filter name="prefersGIF" compare="PreferredImageMIME" argument="image/gif"/>
    <filter name="prefersWBMP" compare="PreferredImageMIME" argument="image/vnd.wap.wbmp"/>
    <filter name="supportsColor" compare="IsColor" argument="true"/>
    <filter name="supportsCookies" compare="Cookies" argument="true"/>
    <filter name="supportsJavaScript" compare="Javascript" argument="true"/>
    <filter name="supportsVoiceCalls" compare="CanInitiateVoiceCall" argument="true"/>
</deviceFilters>

範例

下列範例會設定比較篩選條件和評估工具委派篩選條件。

<deviceFilters>
  <filter name="IsHtml" 
    compare="PreferredRendering" 
    argument="html32" />
  <filter name="IsGPSEnabled" 
    type="MyApplication.MyCapabilityEvaluators,MyApplication" 
    method="IsGPSEnabled" />
</deviceFilters>

項目資訊

Configuration Section Handler

System.Web.Mobile.DeviceFiltersSection

Configuration Member

SystemWebSectionGroup.DeviceFilters

Configurable Locations

Machine.config

根層次的 Web.config

應用程式層級的 Web.config

Web.config

Requirements

IIS 5.0、IIS 5.1 或 IIS 6.0

.NET Framework 1.1 或 2.0

Visual Studio 2003 或 Visual Studio 2005

請參閱

工作

HOW TO:使用位置設定來設定特定的目錄

HOW TO:鎖定 ASP.NET 組態設定

參考

system.web 項目 (ASP.NET 設定結構描述)

configuration 項目 (一般設定結構描述)

deviceFilters 的 filter 項目 (ASP.NET 設定結構描述)

mobileControls 項目 (ASP.NET 設定結構描述)

MobileCapabilities

System.Configuration

System.Web.Configuration

概念

ASP.NET 組態檔階層架構和繼承

保護 ASP.NET 組態

ASP.NET 組態案例

其他資源

Using Device Filters

ASP.NET Mobile Web Pages

建立 ASP.NET Mobile Web 網頁

一般組態設定 (ASP.NET)

ASP.NET 組態設定

ASP.NET 網站管理

ASP.NET 組態檔

ASP.NET 組態 API