Moved

by John 5/22/2008 6:00:00 AM

So I flicked the switch.

Most of the old urls seem to be working and redirecting to the new site. I'm running into a problem with dots being a special character in routing in a few places, so I think I'm going to wait for the next ASP.Net MVC preview rather than fixing it myself :) . More information about the routing changes can be found here.

As I said in my moving post, I switched to BlogEngine.Net running against Blackfish. The redirection of some the urls from my old blog is handled by a web application I developed using ASP.Net MVC and ECO.

I'll be blogging about my data provider in upcoming posts, until then here is a teaser of the Eco BlogEngine model.

 



I noticed that Google Reader seems to be showing all my old posts as new, I'm not sure why thats happened but I'm sorry. :)

 

I guess it means it sort of worked, I'm hoping this post appears as well. :)

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

Providers | Blackfish | ECO | Delphi

ASP.Net Profiles, Anonymous Users and ProfileCommon

by john 11/25/2007 5:33:00 AM

Its easy storing user specific information using the profile feature. When writing web sites as opposed to web applications a strongly typed object called profile is added to the webpage. This object defines a mapping to the profile section in web.config.
 

For example 

        <profile defaultProvider="AspNetAdoProfileProvider">
            <properties>
                <group name="UserDetails" >
                  <add name="State"   type="System.String" allowAnonymous="true" />
                </group>
            </properties>
        </profile>
 

Would be

self Profile.UserDetails.State in your Delphi codebehind, unfortunately Delphi only supports web applications.

so your left with a more verbose version which would be

self.Context.Profile.GetProfileGroup('UserDetails').GetPropertyValue('State').ToString;

This is not something I'm going to easily remember, so its Class Helpers to the rescue again.

 

I started off by adding a Profile property to my webpage base class.

 

  ProfileWebApplicationPage=class(Page)
  public
    function get_Profile: ProfileBase;
  published

  published
    property Profile:ProfileBAse read get_Profile;

  end;
 

function ProfileWebApplicationPage.get_Profile: ProfileBase;
begin
  result:=self.Context.Profile;
end;

 

And I then introduced the first class helper for Profilebase

  ProfileCommon=class helper for ProfileBase
  public
    function GetProfile(username:string):ProfileBase;virtual;
    function get_ProfileGroupUserDetails: ProfileGroupBase;
  published
    property UserDetails:ProfileGroupBase read get_ProfileGroupUserDetails;
  end;


and then a second for  ProfileGroupBase

 

  ProfileGroupUserDetails=class helper for ProfileGroupBase
  published
    public property Zip: string read get_Zip write set_Zip;
    public property Address: string read get_Address write set_Address;
    public property City: string read get_City write set_City;
    public property Email: string read get_Email write set_Email;
    public property GetNewsletter: boolean read get_GetNewsletter write set_GetNewsletter;
    public property Phone: string read get_Phone write set_Phone;
    public property State: string read get_State write set_State;
  end;

And now the the following will appear in Code Completion and Compile
 

  anonymousProfile := Profile.GetProfile(args.AnonymousID);

  if (Profile.LastActivityDate = DateTime.MinValue)then
  begin
    Profile.UserDetails.Address := anonymousProfile.UserDetails.Address;
     Profile.Save();

  end;


 The full source for the example can be found in codecentral. This example also demontrates how anonymous profiles can be migrated to a new website user using the Profile_OnMigrateAnonymous event in Global.asax

 

If you run the example default.aspx should be displayed in your browser

 

 

You have entered the site as an anonymous user, you can now click on the profile link and head over to the profile page. In this page you enter your profile and hit the save button.

You are now ready to use the create user menu option. If you enter your new user details and hit the create user button you end up here.

 

When the user hits the continue button the Profile_OnMigrateAnonymous event is fired and the code inside the event handler in Global.asax is executed.

  anonymousProfile := Profile.GetProfile(args.AnonymousID);

  if (Profile.LastActivityDate = DateTime.MinValue)then
  begin
    Profile.UserDetails.Address := anonymousProfile.UserDetails.Address;
    Profile.UserDetails.City := anonymousProfile.UserDetails.City;

    Profile.UserDetails.State := anonymousProfile.UserDetails.State;
    Profile.UserDetails.Zip := anonymousProfile.UserDetails.Zip;
    Profile.UserDetails.Email := anonymousProfile.UserDetails.Email;
    Profile.UserDetails.Phone := anonymousProfile.UserDetails.Phone;
    Profile.UserDetails.GetNewsletter := anonymousProfile.UserDetails.GetNewsletter;
    Profile.Save();

    ProfileManager.DeleteProfile(anonymousProfile.UserName);
    AnonymousIdentificationModule.ClearAnonymousIdentifier();

 

This code migrates the profile for the anonymous user over to the newly created user.

 

Currently rated 2.3 by 3 people

  • Currently 2.333333/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

Blackfish | ASP.Net 2.0 | Delphi | Providers

Powered by BlogEngine.NET 1.3.0.0
Theme by Mads Kristensen

About the author

Name of author John Moshakis
I'm a software developer living in Toronto..

E-mail me Send mail

Calendar

<<  November 2017  >>
MoTuWeThFrSaSu
303112345
6789101112
13141516171819
20212223242526
27282930123
45678910

View posts in large calendar

Pages

    Recent posts

    Recent comments

    Authors

    Tags

    Don't show

      Disclaimer

      The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

      © Copyright 2017

      Sign in