Solved

ASP.NET Profiles Query

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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

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…
A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

708 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

16 Experts available now in Live!

Get 1:1 Help Now