配置文件内容检查是否设置?
使用 asp.net 配置文件,我存储了一个复杂类型(类)并检索了它。但它返回的是一个未初始化的新对象而不是 null?这是预期的行为吗?如果是,我如何确定是否已为给定用户保存数据?
应该是一些容易让人掌握的要点。
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..
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您的问题有点不清楚,但我认为您是在问为什么您尚未为其存储数据的用户有一个非空配置文件数据对象?
本文可能会为您澄清这一点。一些相关的位:
再往下:
如果您需要跟踪用户之前是否设置过配置文件数据,您可以使用 FindProfilesByUserName 函数用于在登录之前检查配置文件是否存在。
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:
And further down:
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.
有点晚了,但是 UsingDefaultValue 告诉您属性值是来自用户配置文件设置还是使用默认值。另一种可以获得相同结果的方法是使用 反序列化。
A little late, but UsingDefaultValue tells you if the property value is coming from the user profile settings or if it's using a default. Another way you can get, kind of, the same result is using Deserialized.