简介如果设置内容检查? [英] Profiles content check if set?

查看:108
本文介绍了简介如果设置内容检查?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用asp.net的配置文件,我已经存储的复杂类型(类),并取回它。但它返回未初始化的而不是空的新对象?这是预期的行为,如果是这样我怎么能确定我是否已经保存所给用户的数据?

Using asp.net profiles, I've stored a complex type (class) and retrieved it. But it is returning a new object that is not initialized instead of null? Is this the expected behavior, if so how can I determine if I've saved data for the given user?

应该是一些简单的点,有人拿起电话..

should be some easy points for someone to pick up..

推荐答案

您的问题有点不清楚,但我想你问为什么有对谁没有存储数据的用户一个非空的配置文件数据对象对了吗?

Your question is a little unclear, but I think you're asking why there's a non-null profile data object for a user who you haven't stored data for yet?

本文可能希望它清除掉你。一些相关的位:

This article might hopefully clear it up for you. Some of the relevant bits:

用户配置文件是集合
  值的ASP.NET 2.0运行时
  组作为一个公共领域
  动态生成的类。班上
  是从提供系统衍生
  类和扩展与
  另外一些新的成员。该
  类没有被标记为
  序列化,但其内容是
  保存到所述存储介质中
  单个属性。存储
  发生在每个用户的基础上,并且
  preserved直到管理员
  删除它。

A user profile is a collection of values that the ASP.NET 2.0 runtime groups as public fields of a dynamically generated class. The class is derived from a system-provided class and is extended with the addition of a few new members. The class doesn't have to be marked as Serializable, however its contents are persisted to the storage medium as individual properties. The storage occurs on a per-user basis and is preserved until an administrator deletes it.

进一步回落:

在运行应用程序和网页
  显示,ASP.NET动态
  创建一个包含简档对象
  正确类型的数据并分配
  为登录用户的当前设置
  在数据中定义的属性
  模型。轮廓对象被添加到
  当前HttpContext对象和
  提供给通过网页
  配置文件属性。假设
  剖面模型已被定义为
  链接列表存储为一个集合,
  以下code片断显示了如何
  检索最喜爱的链接列表
  由给定用户创建

When the application runs and a page is displayed, ASP.NET dynamically creates a profile object that contains properly typed data and assigns the current settings for the logged user to the properties defined in the data model. The profile object is added to the current HttpContext object and made available to pages through the Profile property. Assuming that the profile model has been defined to store a list of links as a collection, the following code snippet shows how to retrieve the list of favorite links that are created by a given user:

...

这code假设在房地产相关链接
  轮廓对象引用
  集合类型。当页面是
  加载,链接和其它性能
  初始化为最
  最近存储的值;当页面
  被卸载的当前内容
  存储到持久网上平台。

This code assumes a Links property in the profile object that references a collection type. When the page is loaded, Links and other properties are initialized to contain the most recently stored values; when the page is unloaded their current contents are stored to the persistent medium.

如果您需要跟踪用户是否已以往任何时候都设置配置文件数据,你也许可以使用 FindProfilesByUserName 函数来检查,看是否有配置文件存在登录他们面前。

If you need to track whether a user has ever set profile data before, you might be able to use the FindProfilesByUserName function to check to see if a profile exists before you log them in.

这篇关于简介如果设置内容检查?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆