Share via


profile 的 properties 元素(ASP.NET 设置架构)

[本文档仅供预览,在以后的发行版中可能会发生更改。包含的空白主题用作占位符。]

定义用户配置文件属性和属性组的集合。

此元素是 .NET Framework 2.0 版中的新元素。

<properties>
    <add... />
    <clear />
    <remove... />
    <group>...</group>
</properties>

特性和元素

以下几节描述了特性、子元素和父元素。

特性

无。

子元素

元素

说明

add

可选元素。

向用户配置文件添加属性。

clear

可选元素。

从用户配置文件中清除以前定义的所有属性。

group

可选元素。

定义用户配置文件属性的分组。

remove

可选元素。

从用户配置文件中移除属性。

父元素

元素

说明

configuration

指定公共语言运行时和 .NET Framework 应用程序所使用的每个配置文件中均需要的根元素。

system.web

为 ASP.NET 配置节指定根元素。

profile

为应用程序配置用户配置文件。

备注

有关访问和修改应用程序代码中 profile 元素的配置值的信息,请参见 ProfileSection

示例

下面的示例 Web.config 文件指定一个用户配置文件,该配置文件包含字符串类型的 ZipCode 属性和 StringCollection 类型的 RecentSearchList 属性。 所生成的 Profile 将是每个指定属性的强类型访问器。 若要查看用户配置文件的信息以及设置和读取用户配置文件属性的示例,请参见 ASP.NET Profile Properties Overview

<configuration>
   <connectionStrings>
       <add name="SqlServices" connectionString="Data Source=localhost;Integrated Security=SSPI;Initial 
            Catalog=aspnetdb;" />
   </connectionStrings>

  <system.web>
   <anonymousIdentification enabled="true" />

   <profile defaultProvider="SqlProvider" >
     <providers>
       <add
         name="SqlProvider"
         connectionStringName="SqlServices"
         applicationName="HttpProfileBaseApplication"
         type="System.Web.Profile.SqlProfileProvider" />
     </providers>

     <properties>
       <add name="ZipCode" allowAnonymous="true" />
       <add name="RecentSearchList"
            type="System.Collections.Specialized.StringCollection"
            serializeAs="Xml"
            allowAnonymous="true" />
      </properties>
    </profile>
   </system.web>
</configuration>

元素信息

配置节处理程序

System.Web.Configuration.ProfileSection

配置成员

SystemWebSectionGroup.Profile

可配置的位置

Machine.config

根级别的 Web.config

应用程序级别的 Web.config

要求

Microsoft Internet 信息服务 (IIS) 版本 5.0、5.1 或 6.0

.NET Framework 2.0 版

Microsoft Visual Studio 2005

请参见

任务

How to: Lock ASP.NET Configuration Settings

参考

profile 元素(ASP.NET 设置架构)

system.web 元素(ASP.NET 设置架构)

<configuration> 元素

profile 的 properties 的 add 元素(ASP.NET 设置架构)

profile 的 properties 的 clear 元素(ASP.NET 设置架构)

profile 的 properties 的 group 元素(ASP.NET 设置架构)

profile 的 properties 的 remove 元素(ASP.NET 设置架构)

ProfileSection

System.Configuration

System.Web.Configuration

概念

ASP.NET Profile Properties Overview

ASP.NET Configuration Overview

ASP.NET Server Controls and Browser Capabilities

Securing Configuration

Configuration Inheritance

其他资源

ASP.NET Configuration Files

ASP.NET 配置设置

常规配置设置 (ASP.NET)

ASP.NET Configuration API