profile 元素(ASP.NET 设置架构) :使用 ASP.NET 配置文件来配置用于管理用户配置文件值的参数。

吕的部落格唯女子与小人为难养也近之则不孙远之则怨

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

使用 ASP.NET 配置文件来配置用于管理用户配置文件值的参数。

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

<configuration> 元素
  system.web 元素(ASP.NET 设置架构)
    profile 元素(ASP.NET 设置架构)
<profile
enabled="true|false"
inherits="fully qualified type reference"
automaticSaveEnabled="true|false"
defaultProvider="provider name">
<properties>...</properties>
<providers>...</providers>
</profile>
属性和元素属性和元素

下面几部分描述了属性、子元素和父元素。

属性

 
属性 说明

enabled

可选的 Boolean 属性。

指定是否启用 ASP.NET 用户配置文件。如果为 true,则启用 ASP.NET 用户配置文件。

默认值为 true

defaultProvider

可选的 String 属性。

指定默认配置文件提供程序的名称。

有关更多信息,请参见 Provider

默认值为 AspNetSqlProfileProvider

inherits

可选的 String 属性。

包含从 ProfileBase 抽象类派生的自定义类型的类型引用。ASP.NET 动态地生成一个从该类型继承的 ProfileCommon 类,并将该类放在当前 HttpContextProfile 属性中。

automaticSaveEnabled

可选的 Boolean 属性。

指定用户配置文件是否在 ASP.NET 页执行结束时自动保存。如果为 true,则用户配置文件在 ASP.NET 页执行结束时自动保存。

只有在 ProfileModule 对象检测到某一用户配置文件已修改的情况下,该模块才保存该配置文件。也就是在 IsDirty 属性为 true 的情况下。有关更多信息,请参见 ASP.NET 配置文件属性

默认值为 true

子元素

 
元素 说明

properties

必选的元素。

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

providers

可选的元素。

定义配置文件提供程序的集合。

父元素

 
元素 说明

configuration

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

system.web

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

备注备注

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

默认配置默认配置

下面的默认 profile 元素在 .NET Framework 版本 2.0 的 Machine.config 文件中配置。

<profile>
<providers>
<add name="AspNetSqlProfileProvider" connectionStringName="LocalSqlServer" applicationName="/" type="System.Web.Profile.SqlProfileProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</providers>
</profile>
示例示例

下面的代码示例演示如何配置 ASP.NET 应用程序的 Web.config 文件以使用 SqlProfileProvider 提供程序。

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

<system.web>
<authentication mode="Forms" >
<forms loginUrl="login.aspx" name=".ASPXFORMSAUTH" />
</authentication>

<authorization>
<deny users="?" />
</authorization>

<membership defaultProvider="SqlProvider" userIsOnlineTimeWindow="15">
<providers>
<clear/>
<add name="SqlProvider"
type="System.Web.Security.SqlMembershipProvider"
connectionStringName="SqlServices"
applicationName="SampleApplication"
enablePasswordRetrieval="true"
enablePasswordReset="true"
passwordFormat="Encrypted"
requiresQuestionAndAnswer="true" />
</providers>
</membership>

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

<properties>
<add name="ZipCode" />
<add name="CityAndState" />
</properties>
</profile>
</system.web>
</configuration>
元素信息元素信息
 

配置节处理程序

System.Web.Configuration.ProfileSection

配置成员

System.Web.Configuration.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

请参见请参见

任务

如何:锁定 ASP.NET 配置设置

参考

system.web 元素(ASP.NET 设置架构)
<configuration> 元素
profile 的 properties 元素(ASP.NET 设置架构)
profile 的 providers 元素(ASP.NET 设置架构)
ProfileSection
System.Configuration
System.Web.Configuration

概念

ASP.NET 配置概述
ASP.NET Web 服务器控件和浏览器功能
保证 ASP.NET 配置的安全
ASP.NET 配置方案

其他资源

ASP.NET 配置文件属性
ASP.NET 配置文件
ASP.NET 配置设置
常规配置设置 (ASP.NET)
ASP.NET 配置 API
所属分类:技术手册标签:asp.netmembership profile元素ASP.NET设置架构 吕 @ 2007年1月6日14点28分 PM 编辑 profile 元素(ASP.NET 设置架构) 阅读(2241) 评论(0)

相关文章

数据加载中,请稍候……