Solved

ASP.NET Profiles Query

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

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

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

Suggested Solutions

Lots of people ask this question on how to extend the “MembershipProvider” to make use of custom authentication like using existing database or make use of some other way of authentication. Many blogs show you how to extend the membership provider c…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

762 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