Solved

ASP.NET Profiles Query

Posted on 2011-03-06
2
256 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

912 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now