473,756 Members | 1,808 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

profile values sometimes empty?


I've added a number of additional properties to my profile. Sometimes, the
values are populated when the user is retrieved from the database, but
sometimes the values are empty/default. How can I make sure that the values
are always populated correctly?

Further example, my website is working reliably enough, but I'm trying to
access the user profiles from an offline application, and very few of the
custom properties are being returned to my offline application (whereas they
are still visible in the online app).

3 questions:

1) What's the proper way to read a user's profile from an offline
application/class library. I am currently using
System.Web.Prof ile.ProfileBase .Create(usernam e, true). I'll be looping
through profiles in a batch job.

2) Why is my offline app not showing all of the profile properties (but is
showing some of them? I have the same entries in my app.config file as on my
website. (yes even made sure that they are under <system.web>)

3) In my website, why are my custom property values sometimes empty? If I
need to "get profile for user X" even if user x isn't the current user,
what's the correct procedure?

--
Eric Falsken
Technical Evangelist: db4o
http://www.db4o.com
Nov 28 '06 #1
9 3107
Hello Eric,

Based on my understanding, you have an ASP.NET 2.0 web application which
use the profile service to store some custom properties for membership
users. Also, you has another offline application that will need to read the
profile datas (properties for users in that application), but met some
problems,correc t?

As for the offline application , is it also an ASP.NET application and
configure to use the same profile datasource provider or is it a
winform/console application?

Regarding on the three questions you mentioned, here are my suggestions:

1) What's the proper way to read a user's profile from an offline
application/class library. I am currently using
System.Web.Prof ile.ProfileBase .Create(usernam e, true). I'll be looping
through profiles in a batch job.
=============== =============== ========
If your offline appliation is also an ASP.NET application which has
configured to use the same profile provider and database as your main
application. You can simply use the following code to loop all the users'
profiles and properties:

<<<<<<<<<<<<<<< <<<<<
public partial class ProfilePage : System.Web.UI.P age
{
protected void Page_Load(objec t sender, EventArgs e)
{

DumpProfile();
}

protected void DumpProfile()
{
//I didn't involve anonymous records
ProfileInfoColl ection pis =
ProfileManager. GetAllProfiles( ProfileAuthenti cationOption.Au thenticated);

foreach (ProfileInfo pi in pis)
{
ProfileBase pb = ProfileBase.Cre ate(pi.UserName );

Response.Write( "<br/>user: " + pb.UserName);

foreach (SettingsProper ty sp in ProfileBase.Pro perties)
{
Response.Write( "<br/>" + sp.Name + ": " +
pb.GetPropertyV alue(sp.Name));
}
}
}
}
>>>>>>>>>>>>>>> >>>>>


2) Why is my offline app not showing all of the profile properties (but is
showing some of them? I have the same entries in my app.config file as on
my
website. (yes even made sure that they are under <system.web>)
=============== =============== =
As you mentioned App.config, is the offline application an non-ASP.NET one?
As far as I know, for two ASP.NET application, as long as they use the same
profile database setting (in provider) they can share the profile datas. I
haven't tried a non-ASP.NET context, I'll perform some research on this,
however, this case(read profile in non-ASP.NET context) is not originally
designed for.
3) In my website, why are my custom property values sometimes empty? If I
need to "get profile for user X" even if user x isn't the current user,
what's the correct procedure?
=============== =============== =============== ===

the same as the code I've provided in Q1

I'll update you as soon as I get any update. Meanwhile, if you have any
other questions or ideas, please feel free to post here.
Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

=============== =============== =============== =====

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.

=============== =============== =============== =====

This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 28 '06 #2

Hello Eric,

I have just performed some further test to loop through all the properties
of each user in profile database in non-ASP.NET context and that also
worked well.

I've used a winform application which duplicate the same <profilesetti ng
with an ASP.NET web application. And the following code can correct dump
all the users(include both authenticated and anonymous identified users):

=============== ==========
public partial class Form1 : Form
{
SqlProfileProvi der _profile;

public Form1()
{
InitializeCompo nent();
}

private void btnDump_Click(o bject sender, EventArgs e)
{
Dump_Profile();
}

private void Dump_Profile()
{

ProfileInfoColl ection pis =
ProfileManager. GetAllProfiles( ProfileAuthenti cationOption.Al l);

txtOutput.Text += "\r\n=========T otal Profile Count: " +
pis.Count + "========== ";
txtOutput.Text += "\r\n\r\n";

foreach (ProfileInfo pi in pis)
{
ProfileBase pb = ProfileBase.Cre ate(pi.UserName );

txtOutput.Text += "\r\n\tProf ile for " + pi.UserName +"\t";

foreach (SettingsProper ty sp in ProfileBase.Pro perties)
{
txtOutput.Text += "\r\n****" + sp.Name + "(" +
sp.PropertyType .Name + "): " + pb.GetPropertyV alue(sp.Name);
}

txtOutput.Text += "\r\n";
}
}

private void Form1_Load(obje ct sender, EventArgs e)
{
_profile = new SqlProfileProvi der();
}
}

=============== =============== =========

One thing I'm wondering is whether you've used custom data object(custom
class) that will need particular serialiation. I haven't tried this so far.

Anyway, please feel free to let me know if you have any questions.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

This posting is provided "AS IS" with no warranties, and confers no rights.
Nov 28 '06 #3
I am using WinForms/Console application to read these profiles. my app.config
contains a <system.webwi th all the same profile contents, except a
different profile provider. The profiles were originally stored by using
Community Server. But lookin at their code, it looks like it should still
store the data the same. Do you think that could be the problem? Is the
deserialization of the profile bag that sensitive?

Nov 28 '06 #4
I am using WinForms/Console application to read these profiles. my
app.config
contains a <system.webwi th all the same profile contents, except a
different profile provider. The profiles were originally stored by using
Community Server. But lookin at their code, it looks like it should still
store the data the same. Do you think that could be the problem? Is the
deserialization of the profile bag that sensitive?
I dug into their provider with reflector, and the are not doing anything
strange in there. So I replaced the CS profile provider with the MS standard
SQL provider, and the site still works. And all profile data is showing up
still. Unfortunately, my WinForms app still refuses to load a majority of my
custom fields.

Fields like these are just empty when I load from my WinForms application.
But are populated just fine on my webserver.

<add name = "preferredLangu age" type="string"/>
<add name = "newsletterOptO ut" type="System.Bo olean"/>
<add name = "alternateEmail " type="string"/>
Nov 28 '06 #5
Hello Eric,

Thanks for your reply.

Yes, from the reflector diassembled code, the SqlServer service providers
can be runnining in non-ASP.NET context as well. I've also tried this
(membership, role, profile providers...) in a winform application and that
works. My local test also use some simple type properties(two string
properties ...) and I've also enabled anonymousIdenti fication. Currently,
I haven't found any particular difference from yours an my offline
application, are you using the similar code to query the profile db as I
posted in the previous message?

If you feel necessary, you can ping me at st*****@microso ft.com and I can
send you my test winform project.
Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 29 '06 #6
Hello Eric,

How are you doing on this issue, have you got any progress. Or if you do
feel it hard to generate a simple repro page and this is an urgent issue, I
would suggest you contact the CSS for further assistance.

http://support.microsoft.com/

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.
Dec 1 '06 #7
I'm finding it rather easy to reproduce, actually. There must be something
simple that I am missing. I'm getting some of the profile values, and all the
rest of the fields are coming back, but empty. Values saved with one app are
not available to the other.

I'm using identical code for the profile provider in my app and web.config
files, but there's definately something wierd going on.

Can anyone else confirm that they are able to read profile values from a
database written by CommunityServer ? I've upgraded to 2.1 and am using the
aspnet2 membership option.

--
Eric Falsken
Technical Evangelist: db4o
http://www.db4o.com

Dec 2 '06 #8
Thanks for your reply Eric,

It seems a bit unexpected that your offline app can not get the value. Do
feel necessary I send you a test application and you can customize it so as
to repro the behavior. thus, I can perform some local tests against it.

BTW, what's the community server you mentioned?
Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.

Dec 4 '06 #9
Hi Eric,

I have just sent you my test applications. Please feel free to post here if
you have any new finding.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.
Dec 6 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
1769
by: givlerj | last post by:
I need some help. Here is a little background, I support a MS Access 2k DB (SQL Server 2k backend) that has courses and students. The problem form lets the user pick a course from a drop down and opens a report of the students attending the course in the dropdown. A user can't view on 1 course in the dropdown list. He can view other courses but not this one. Other users on other computers can view the course just fine. Furthermore, I was...
6
2226
by: Shimon Sim | last post by:
Hi I am working on application that need to hold custom user information - Last and first name, email, some other domain related information. I used to create Base class for all my pages. The base class would have CurrentUser property that would hold customer class in session and that was fine for all my situations. Now ASP.NET 2.0 came and we have Profile property for pages that could be extended with configuration to have custom...
4
2594
by: Antonio Tirado | last post by:
Hi, I'm using the OleDB namespace to open a CSV File. I can read the file sucessfully except for hyphenated values. My CSV File contains phone numbers and sometimes these come separated with hyphens (ie: 555-123-4567). These fields come as empty using the OleDB namespace and as dbNull when using the ODBC namespace. Is there a way to prevent this from happening? Thanks in advance,
0
1836
by: a | last post by:
I need to create an instance of a custom object 'School.Teacher' and use it in a Profile object. I'm developing a bad case of "Pretzel Logic" thinking about this. Filling the custom object 'School.Teacher' as an ArrayList creates the proper information (see aspx code below), but I'm unable to use this ArrayList in the Profile object. The aspx code below shows the attempt and error message.
2
1677
by: Darius | last post by:
Hello I implemented custom profile provider based on the example at http://msdn2.microsoft.com/en-us/library/ta63b872.aspx. It reads Profiles values from tables in Sql Server. Everytime when I read Profile property (e.g. string Name = Profile.FirstName) GetPropertyValues function is called. However after this function SetPropertyValues is also called. It does not make sense why this method should be called even if I do not update...
0
1060
by: shapper | last post by:
Hi, I am creating a new user using the following: Membership.CreateUser(tbUsername.Text, tbPassword.Text, tbEmail.Text, String.Empty, String.Empty, False, status) Now I need to add profile data to this. Do I need to authenticate it before I do so? Something like:
11
2096
by: Weston Weems | last post by:
I've got the need to have user information for logged in user in a readily avaliable page context (a lot like how Profile is) except not suck. Before we jump to any conclusions, from what I gathered, the implementation of the provider model is absolute garbage. While I've seen microsoft employees make other questionable design decisions, I cant possibly fathom why a user profile cant be derived as some other object.
23
2072
by: florian.loitsch | last post by:
According to the spec Section 14 the production SourceElements:SourceElements SourceElement is evaluated as follows: 1. Evaluate SourceElements. 2. If Result(1) is an abrupt completion, return Result(1) 3. Evaluate SourceElement. 4. Return Result(3). If I understood correctly the following program should alert 'undefined': alert(eval('3;;'));
5
1669
by: Steven | last post by:
I have the following in my web.config: <system.web> <profile defaultProvider="MyASPSqlProfileProvider" enabled="true" > <properties> <add name="FirstName" defaultValue="" type="string"/> <add name="MiddleInitial" defaultValue="" type="string" /> <add name="LastName" defaultValue="" type="string"/> <add name="Address1" defaultValue="" type="string"/> <add name="Address2" defaultValue="" type="string"/> <add name="City" defaultValue=""...
0
9456
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9872
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9843
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9713
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8713
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6534
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5142
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5304
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3805
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.