Monday, February 26, 2007

How To: Read Profile outside of ASP.NET

first of all thanks to daniel larson with his blog entry :-)

in case you're using your own classes and not just properties then here a small overview what you need to do:

namespace YourNameSpace.Profile.Extension

/// UserAddress contains the users address information,
/// this class is used in the profile .net 2.0 approach

public class UserAddress
public UserAddress() { }

#region Property: Street
private string street;

/// Gets/sets the Street

public string Street
get { return this.street; }

set { this.street = value; }

... all you other stuff ....

the web.config looks like this:

<add name="UserAddress" type="YourNameSpace.Profile.Extension.UserAddress" serializeAs="Xml"/>

and finally in your code you run the following code lines:

ProfileBase profile = ProfileBase.Create(data.Login);

string street = (profile.GetPropertyValue("UserAddress") as Profile.UserAddress).Street;

No comments:

Shared Cache - .Net Caching made easy

All information about Shared Cache is available here: Its free and easy to use, we provide all sources at codeplex.

Facebook Badge