Help with understanding Profiles

Aug 2, 2008 at 9:18 AM

I am very new to profiles and profiles in 1.4.5. Could someone please explain to me how it works. Is it only supposed to be visible to the admin? To my understanding this is how its supposed to work:

1. I create or update the profile for lets say the admin and put in his details such as Country and Photo.( and btw a browse button for the photo will be very helpful)
2. The admin posts and article and on the article it says "by admin"
3. When someone clicks the admin link, it should open a page or popup displaying his Country and Photo

Isn't that how profiles work? Currently when I click the admin link on the article it only shows all posts made by him and not his profile. Am I missing something or do I need to do some additional coding. The only thing that works in the profile is the "Display Name"

Sorry for being such a noob but hey i'm a learner and new to BlogEngine.
Looking forward to positive feedback.


Aug 2, 2008 at 9:36 PM
From a usability perspective that would make sense, but that's now how BE.Net is set up.  When you click on the users name, BE.Net shows a list of posts that where authored by that user, hence the link /author/admin.aspx
Aug 4, 2008 at 8:11 AM
Well so what use is are the Profiles if its not visible to the public. I'm sure there is some use to it. It can't just be for admin use. Why does the admin want to know profiles for other users/ editors.

Anyway if someone can tell me what use it is, will appreciate.
Aug 5, 2008 at 3:05 AM
Personally, the implementation of what exactly should be shown on a profile page is subjective to personal preference.  You could always write you own code to show the profile as want to display, but I do agree there should be a standard view profile page which has a link to show posts by this author, and the profile should be displayed when you click on the author.  I imagine most installations will really have only one user, and clicking on the author page and showing that author's posts does not make sense.

Here's a quick and dirty implementation that can get a profile page up and running in two minutes without writing a single line of code!!!.

Create a new page called authors.aspx in visual studio and drag a gridview onto the page. In the gridview tasks in the datasource drop downlist select new data source.

select object datasource and click ok.  in the choose your business object dropdownist uncheck show only data components and select profile common ( hint you can go directly to objects that start with p by typing p while the the dropdown has focus). Click next  Under the select a method tab choose GetProfile(username string). Click next

On the parameter name dropdownlist choose query string and then in the querystring field type "author" (without the quotes).  Click Finish.

Now You can open the page Author.aspx?author=[Author's username here] and the users profile will show up

GREAT!!! But that's not pretty so lets fix it.

Back in Visual Studio click on the GridView tasks again and choose "Edit colums"  in the bottom left you see a list box that is labeled selected fields.
Highlight each column then click the link on the right that says "Convert this field to a template field". When your all done click "OK"... Now switch to HTML view.

Delete every <EditItemTemplate> html tag (including it innercontents).  Now cut  every asp tag inside of a <itemtemplate> and paste them first  <itemplatefield>you find.  Then place a <br /> tag
in between each contro you find  in that first item template. Then delete every other <asp:templatefield> and its inner contents except the first one with all the server controls.

When you are done your code will probably resemble somthing like this

 <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataSourceID="ObjectDataSource1">
                    <asp:Label ID="Label12" runat="server" Text='<%# Bind("UserName") %>'></asp:Label>
                    <br />
                    <asp:Label ID="Label1" runat="server" Text='<%# Bind("Occupation") %>'></asp:Label>
                    <br />
                    <asp:Label ID="Label2" runat="server" Text='<%# Bind("FirstName") %>'></asp:Label>
                    <br />
                    <asp:Label ID="Label3" runat="server" Text='<%# Bind("Company") %>'></asp:Label>
                    <br />
                    <asp:Label ID="Label4" runat="server" Text='<%# Bind("EmailAddress") %>'></asp:Label>
                    <br />
                    <asp:Label ID="Label5" runat="server" Text='<%# Bind("JobRoles") %>'></asp:Label>
                    <br />
                    <asp:Label ID="Label6" runat="server" Text='<%# Bind("LastName") %>'></asp:Label>
                    <br />
                    <asp:Label ID="Label7" runat="server" Text='<%# Bind("Website") %>'></asp:Label>
                    <br />
                    <asp:Label ID="Label8" runat="server" Text='<%# Bind("NumberOfEmployeesInCompany") %>'></asp:Label>
                    <br />
                    <asp:Label ID="Label9" runat="server" Text='<%# Bind("JobTitle") %>'></asp:Label>
                    <br />
                    <asp:Label ID="Label10" runat="server" Text='<%# Bind("LastUpdatedDate") %>'></asp:Label>
                    <br />
                    <asp:Label ID="Label11" runat="server" Text='<%# Bind("LastActivityDate") %>'></asp:Label>
    <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" SelectMethod="GetProfile"
            <asp:QueryStringParameter Name="username" QueryStringField="author" Type="String" />

From here you can simply rearrange the controls to you like and apply what ever styles you would like. 

I will write a widget/exttension  for this and add it to my blog. Unfortunately, we had a critical server get wiped out at work over the weekend, and I had to format my PC due to a virus.  I am i the process of rebuiling it right now, or I would have just posted this as a sample on my blog for you to download.

Good Luck....

Aug 5, 2008 at 3:07 AM
PS.  Sorry for the bad English/grammar.  I just think so way much faster than I can type and would rather go on helping someone else out than spend 10 minutes proof reading my post.... You should get the point.
Aug 5, 2008 at 4:07 AM
Actually, here you go... quick and dirty and specifically for's default profile (it aint pretty but you can easily clean it up with a little CSS)

/// Authors.aspx.cs by Alexander Higgins,

#region Using

using System;
using System.Web;
using System.Collections.Generic;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using BlogEngine.Core;
using System.Collections;


/// <summary>
/// Displays the profile of the user specified in the "user" querystring. 
/// </summary>
public partial class authors : BlogEngine.Core.Web.Controls.BlogBasePage
    protected void Page_Load(object sender, EventArgs e)
        if ((Request.QueryString["user"] == null))
        // to set the data source dynamically, remote the objectdatasource and uncomment the following lines
        //    ProfileCommon pc =new ProfileCommon().GetProfile(Request.QueryString["user"]);
        //    if(! (pc==null)) {
        //        ArrayList l = new ArrayList();
        //        l.Add(pc);
        //        this.GridView1.DataSource=l;
        //        this.GridView1.DataBind();

        //    }


/// Authors.aspx Alexander Higgins,

%@ Page Language="C#" AutoEventWireup="true" CodeFile="authors.aspx.cs" Inherits="authors" %>

<asp:Content ID="Content1" ContentPlaceHolderID="cphBody" Runat="Server">
       <style type="text/css">
     .span {
    .left {

            <asp:GridView ID="GridView1" runat="server" Width="500" gridlines="none" AutoGenerateColumns="False" DataSourceID="ObjectDataSource1">
                    <asp:TemplateField HeaderText="Author's Profile">
                            <span class="left">Display Name: </span>
                            <asp:Label ID="Label4" runat="server" Text='<%# Bind("DisplayName") %>'></asp:Label>
                            <br />
                            <span class="left">User Name: </span>
                            <asp:Label ID="Label2" runat="server" Text='<%# Bind("UserName") %>'></asp:Label>
                            <br />
                            <span class="left">Full Name: </span>
                            <asp:Label ID="Label9" runat="server" Text='<%# Bind("FullName") %>'></asp:Label>
                            <br />
                            <span class="left">First Name: </span>
                            <asp:Label ID="Label20" runat="server" Text='<%# Bind("FirstName") %>'></asp:Label>
                            <br />
                            <span class="left">Middle Name: </span>
                            <asp:Label ID="Label10" runat="server" Text='<%# Bind("MiddleName") %>'></asp:Label>
                            <br />
                            <span class="left">Last Name: </span>
                            <asp:Label ID="Label19" runat="server" Text='<%# Bind("LastName") %>'></asp:Label>
                            <br />
                            <span class="left">Title: </span>
                            <asp:Label ID="Label5" runat="server" Text='<%# Bind("Title") %>'></asp:Label>
                            <br />
                            <span class="left">Birthday: </span>
                            <asp:Label ID="Label23" runat="server" Text='<%# Bind("Birthday") %>'></asp:Label>
                            <br />
                            <span class="left">City/Town: </span>
                            <asp:Label ID="Label11" runat="server" Text='<%# Bind("CityTown") %>'></asp:Label>
                            <br />
                            <span class="left">Country: </span>
                            <asp:Label ID="Label12" runat="server" Text='<%# Bind("Country") %>'></asp:Label>
                            <br />
                            <span class="left">Address 1: </span>
                            <asp:Label ID="Label13" runat="server" Text='<%# Bind("Address1") %>'></asp:Label>
                            <br />
                            <span class="left">Address 2: </span>
                            <asp:Label ID="Label14" runat="server" Text='<%# Bind("Address2") %>'></asp:Label>
                            <br />
                            <span class="left">RegionState: </span>
                            <asp:Label ID="Label6" runat="server" Text='<%# Bind("RegionState") %>'></asp:Label>
                            <br />
                            <span class="left">Company: </span>
                            <asp:Label ID="Label16" runat="server" Text='<%# Bind("Company") %>'></asp:Label>
                            <br />
                            <span class="left">Industry: </span>
                            <asp:Label ID="Label17" runat="server" Text='<%# Bind("Industry") %>'></asp:Label>
                            <br />
                            <span class="left">Email Address: </span>
                            <asp:Label ID="Label18" runat="server" Text='<%# Bind("EmailAddress") %>'></asp:Label>
                            <br />
                            <span class="left">Phone: </span>
                            <asp:Label ID="Label1" runat="server" Text='<%# Bind("PhoneMain") %>'></asp:Label>
                            <br />
                            <span class="left">Mobile: </span>
                            <asp:Label ID="Label21" runat="server" Text='<%# Bind("PhoneMobile") %>'></asp:Label>
                            <br />
                            <span class="left">Fax: </span>
                            <asp:Label ID="Label8" runat="server" Text='<%# Bind("PhoneFax") %>'></asp:Label>
                            <br />
                            <span class="left">AboutMe: </span>
                            <asp:Label ID="Label3" runat="server" Text='<%# Bind("AboutMe") %>'></asp:Label>
                            <br />
             <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" SelectMethod="GetProfile"
                    <asp:QueryStringParameter DefaultValue="" Name="username" QueryStringField="user"
                        Type="String" />

Aug 5, 2008 at 6:34 AM
Now that's what i'm talking about! Thanks alot. However I think the profile should only show if the user has not marked it as private. Otherwise thanks for the code. Hope you will share the extension once its done :)

Sorry about your server being wiped out.
Aug 13, 2008 at 5:49 PM
Hi,  I've copied your code as suggested but I get an error when try to run it:

public override int GetTypeHashCode() {
return 605710018;
I am trying to display the admin profile using author.aspx?user=admin

What am I doing wrong?

Aug 13, 2008 at 10:45 PM

Hi.. I have corrected the above error.  Still getting errors when trying to run the code Alex provided...darn.

I'm getting errors when binding because the DataSourceID is set and the load is trying to set the DataSource property.  I'm trying this using the standard theme...  I think I'm missing something for sure. 

Alex,  is this just part of the extension you were writing? 


Aug 13, 2008 at 11:25 PM
I you want to dynamically set the data source in the page_load, is in my commented out example, you need to remove the datasourceid attribute from your gridview....

The new start tag should look like this...

<asp:GridView ID="GridView1" runat="server" Width="500" gridlines="none" AutoGenerateColumns="False">
Aug 14, 2008 at 12:39 AM

Hey Alex..

yep,  I had tried that after my post.  Now I get a DataBinding error:

'ProfileCommon' coes not contain a property with the name 'DisplayName'.

Thanks for your help...


Aug 14, 2008 at 1:25 AM
In a stroke of genius, the developement team has decided to abandon the built in Asp.Net Roles and hard code the roles class in BlogEngine.Net 1.4.5.  Well that means you are no longer able to modify the user profiles to fit your own personal needs and you are stuck using their implementation.  If you do decided to dig through the core and change their implementation you can sleep easy knowing that the next time you upgrade your BE installation your application is goind to break into peices.....

Anyway to answer the OP's question, you need to use the new AuthorProfile class instead of the built in Asp.Net Profile simply make this change
ProfileCommon pc =new ProfileCommon().GetProfile(Request.QueryString["user"]);
to this
AuthorProfile pc = AuthorProfile.GetProfile(Request.QueryString["user"]);

If your receive any errors after making that change you will have to remove the correpsonding Bind("What is Being Complained About") from the aspx page.
Aug 14, 2008 at 2:40 AM

Man that's a drag.  Given that I've seen so many enhancement requests for this type of profile access,  so many other engines have this feature.

Maybe the Dev Team will reconsider this?

Thanks for clearing up my confusion anyhow.

Good luck, Vicky

Aug 14, 2008 at 2:52 AM
Alex,  it works now after removing:  Title, Address1, Address2 and Industry from the aspx...  Thanks

I agree that its doesn't seem to make sense for them to lock in the profile usage this way... that's not very 'social' of them...

Still a blognewbie....