Solved

ASP.NET Profiles Query

Posted on 2011-03-06
2
258 Views
Last Modified: 2012-06-27
Hi

I've searched Google for this but cant get a definative answer.

Is there a way to check if a logged in user has a profile? or is it OK to try and read a profile and will it just return empty and not error if one is not found.

Andy
0
Comment
Question by:Andy Green
2 Comments
 
LVL 18

Accepted Solution

by:
carlnorrbom earned 500 total points
ID: 35055096
Hi,

You can do some simple checking like this:
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not Page.IsPostBack Then
            If User.Identity.IsAuthenticated Then
                Dim up As ProfileCommon = Profile.GetProfile(User.Identity.Name)
                If Not up Is Nothing Then
                    lblResult.Text = "User has profile, last updated: " & up.LastUpdatedDate.ToLongDateString()
                Else
                    lblResult.Text = "User profile not created"
                End If
            End If
        End If
    End Sub

Open in new window


If Profile.GetProfile() returns nothing then up should be nothing as well. So simply just do the check and add the needed logic to manage this.

/Carl.
0
 
LVL 3

Author Closing Comment

by:Andy Green
ID: 35179083
Thanks
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

785 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question