472,958 Members | 2,421 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,958 software developers and data experts.

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.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
9 3064
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

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
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
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
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
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
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...
6
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...
4
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...
0
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 ...
2
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...
0
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...
11
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...
23
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...
5
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...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
2
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

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.