易截截图软件、单文件、免安装、纯绿色、仅160KB

如何使用ASP.NET Profile

Asp.Net中有一套与用户相关联的属性设置,可以通过在WebConfig里配置来直接使用,他的作用为
存储和使用唯一与用户对应的信息
展现个人化版本的Web应用程序
用户的唯一身份标识在再次访问时识别用户
Asp.Net Profile提供的跟用户相关的类型都是强类型
首先生成数据库脚本,使用Visual Studio 2005 命令提示,输入命令行aspnet_regsql -A p -sqlexportonly filename
-A:表明增加一个数据库
p:表明生成的是Profile的数据库
-sqlexportonly:表明是倒出sql脚本,用其他参数可以直接创建数据库,具体的说明可以参看aspnet_regsql的帮助说明
filename:保存的文件名和 路径 
现在数据库创建好了,里面有4张表aspnet_Application用来存储应用程序的相关类型,aspnet_Profile用来保存用户的属性信息,aspnet_SchemaVersion用来存储版本信息,aspnet_User用来保存用户信息。可以从这几张表可以看到,多个应用程序可以用同一个数据库来表示用户信息。
下面是如何来配置WebConfig来支持Profile
首先配置连接字符串
<connectionStrings>
<add name="ProfileDatabase" connectionString="Server=192.168.1.2; Initial Catalog=aspnetdb; User ID=sa; Password=sa"/>
</connectionStrings>
然后在system.web节点下添加profile节点
<profile enabled="true" automaticSaveEnabled="true" defaultProvider="SqlProvider">
<providers>
<clear />
<add name="SqlProvider"
type="System.Web.Profile.SqlProfileProvider"
connectionStringName="ProfileDatabase"
applicationName="ProfileSample"
description="Sample for ASP.NET profile and Profile Service" />
</providers>
<properties>
<add name="Name" type="System.String"/>
<add name="Email" type="System.String" />
<add name="Age" type="System.Int32" />
<group name="Address">
<add name="City" type="System.String" />
<add name="Street" type="System.String" />
<add name="PostalCode" type="System.String" />
</group>
</properties>
</profile>
测试成功的配置
<profile enabled="true" automaticSaveEnabled="true" defaultProvider="SqlProvider"  >
     
 


相关文档:

ASP.NET中如何实现FORM认证登录

如何运用 Form 表单认证
ASP.NET 的安全认证,共有“Windows”“Form”“Passport”“None”四种验证模式。“Windows”与“None”没有起到保护的作用,不推荐使用;“Passport”我又没用过,唉……所以我只好讲讲“Form”认 ......

ASP.net 设置默认按钮

 public static void SetEnterControl(System.Web.UI.Control Ctrl)
    {
        Page mPage = Ctrl.Page;
        string mScript;
        mScript = @"<script language=""jav ......

ASP.NET(C#)常用代码30例

1. 打开新的窗口并传送参数:
  传送参数:
response.write("<script>window.open(’*.aspx?id="+this.DropDownList1.SelectIndex+"&id1="+...+"’)</script>")
  接收参数:
string a = Request.QueryString("id");
string b = Request.QueryString("id1");
  2.为按钮添加对话框
Button1 ......

asp.net连接SQL 和ACCESS数据库

ASP.NET如何连接Access或SQL Server数据库 
首先看一个例子代码片断:
程序代码: 
--------------------------------------------------------------------------------
using System.Data;
using System.Data.OleDb;
......
string strConnection="Provider=Microsoft.Jet.OleDb.4.0;";
strConnection+ ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号