次の方法で共有


filter Element for deviceFilters (ASP.NET Settings Schema) 

Provides filtering capability for the MobileCapabilities class.

<filter name="capability"
        compare="capabilityName"
        argument="argument" />
<filter name="capability"
        type="className"
        method="methodName" />

Attributes and Elements

The following sections describe attributes, child elements, and parent elements.

Attributes

Attribute Description

argument

Optional String attribute.

Specifies the argument against which the capability should be compared. If the compare attribute is defined, this attribute is required.

compare

Optional String attribute.

Specifies the browser capability evaluated by the comparison evaluator. The capability can be any built-in capability, or the name of any other custom capability evaluator. If you are specifying a comparison filter, this attribute is required.

method

Optional String attribute.

Specifies the method that supplies the evaluator delegate. Used when specifying an evaluator delegate filter. When the type attribute is specified, this attribute is required and the compare and argument attributes cannot be specified.

name

Required String attribute.

Specifies the unique name by which the filter should be identified.

NoteNote

A filter with the same name as an earlier defined filter (either later in the configuration file or later in the configuration file hierarchy) will override the earlier defined one.

type

Optional String attribute.

Specifies the class type that supplies the evaluator delegate.

Child Elements

None.

Parent Elements

Element Description

configuration

The required root element in every configuration file used by the common language runtime and .NET Framework applications.

system.web

Specifies the root element for the ASP.NET configuration settings in a configuration file. Contains configuration elements that configure ASP.NET Web applications and control how the applications behave.

deviceFilters

Specifies a device or a device class in the ASP.NET MobileCapabilities system based on the user agent or browser.

Remarks

When creating a Web application that has device-specific content, you must add one or more filters in a deviceFilters section in the configuration file. Each filter specifies some criteria against which target devices should be matched.

The device filters configuration provides an evaluation mechanism for two types of filters: a comparison-based filter and an evaluator delegate–based filter. The syntax specifies both types of filters. The first filter shows the comparison-based filter and the second filter shows the evaluator delegate-based filter. For a detailed discussion about creating filters in the configuration file, see Device-Specific Rendering.

Device filters are case sensitive. A filter named "isColor" and a filter named "IsColor" are considered different.

Default Configuration

The following default deviceFilters element is not explicitly configured in the machine configuration file or in the root Web.config file, but is the default configuration returned by application in the .NET Framework version 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>

Example

The following example configures both a comparison filter and an evaluator delegate filter. The first filter shows a comparison-based filter and the second filter shows a evaluator delegate-based filter.

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

Element Information

Configuration Section Handler

System.Web.Mobile.DeviceFiltersSection

Configuration Member

System.Web.Configuration.SystemWebSectionGroup.DeviceFilters

System.Web.UI.MobileControls.DeviceSpecificChoice.Filter

Configurable Locations

Machine.config

Root level Web.config

Application level Web.config

Virtual or physical directory level Web.config

Requirements

IIS 5.0, IIS 5.1, or IIS 6.0

.NET Framework 1.1, or 2.0

Visual Studio 2003, or Visual Studio 2005

See Also

Tasks

How to: Configure Specific Directories Using Location Settings
How to: Lock ASP.NET Configuration Settings

Reference

system.web Element (ASP.NET Settings Schema)
configuration Element (General Settings Schema)
mobileControls Element (ASP.NET Settings Schema)
MobileCapabilities
System.Configuration
System.Web.Configuration

Concepts

ASP.NET Configuration File Hierarchy and Inheritance
Securing ASP.NET Configuration
ASP.NET Configuration Scenarios

Other Resources

Using Device Filters
ASP.NET Mobile Web Pages
Creating ASP.NET Mobile Web Applications
General Configuration Settings (ASP.NET)
ASP.NET Configuration Settings
Configuring ASP.NET Applications
ASP.NET Configuration Files
ASP.NET Configuration API