By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,846 Members | 1,211 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,846 IT Pros & Developers. It's quick & easy.

profile values sometimes empty?

P: n/a

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.Profile.ProfileBase.Create(username, 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
Share this Question
Share on Google+
9 Replies


P: n/a
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,correct?

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.Profile.ProfileBase.Create(username, 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.Page
{
protected void Page_Load(object sender, EventArgs e)
{

DumpProfile();
}

protected void DumpProfile()
{
//I didn't involve anonymous records
ProfileInfoCollection pis =
ProfileManager.GetAllProfiles(ProfileAuthenticatio nOption.Authenticated);

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

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

foreach (SettingsProperty sp in ProfileBase.Properties)
{
Response.Write("<br/>" + sp.Name + ": " +
pb.GetPropertyValue(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

P: n/a

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 <profilesetting
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
{
SqlProfileProvider _profile;

public Form1()
{
InitializeComponent();
}

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

private void Dump_Profile()
{

ProfileInfoCollection pis =
ProfileManager.GetAllProfiles(ProfileAuthenticatio nOption.All);

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

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

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

foreach (SettingsProperty sp in ProfileBase.Properties)
{
txtOutput.Text += "\r\n****" + sp.Name + "(" +
sp.PropertyType.Name + "): " + pb.GetPropertyValue(sp.Name);
}

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

private void Form1_Load(object sender, EventArgs e)
{
_profile = new SqlProfileProvider();
}
}

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

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

P: n/a
I am using WinForms/Console application to read these profiles. my app.config
contains a <system.webwith 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

P: n/a
I am using WinForms/Console application to read these profiles. my
app.config
contains a <system.webwith 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 = "preferredLanguage" type="string"/>
<add name = "newsletterOptOut" type="System.Boolean"/>
<add name = "alternateEmail" type="string"/>
Nov 28 '06 #5

P: n/a
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 anonymousIdentification. 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*****@microsoft.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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.