Writing a custom ASP.NET Profile class - Jon Galloway

Writing a custom ASP.NET Profile class

We made heavy use of the ASP.NET membership and profile system for Video.Show (a Silverlight 1.0 video community website system, available on CodePlex). In addition to storing basic profile information, we created a custom profile with some additional fields. It's a really easy way to add add some additional personalization to your site without having to add a bunch of tables to your database.

This is really simple if you're using a Website Project - you can just add additional properties to the profile section of your web.config, and a custom profile class is generated on the fly when you rebuild your application. That makes things ridiculously easy. First, we'd define the property in web.config:

<!-- In web.config -->
<profile >
  <properties>
    <add name="FavoritePasta" />
  </properties>
</profile>
Then you can refer to the Profile.FavoritePasta profile setting anywhere in your web application, and it's automatically mapped to the current user:
Profile.FavoritePasta = "Pumpkin Ravioli";
And you can access the data just as you would a session property:
<span id="user-favorite-pasta"><%= Profile.FavoritePasta %></span>

Not so fast, I'm using a Web Application Project

Yeah, here's the catch. If you're using the Web Application Project model, the custom build handling for the profile doesn't kick in, so those custom properties you've lovingly crafted in your web.config aren't going to be compiled into a custom profile class.

There's a Visual Studio 2005 add-in called WebProfile that reads your custom profile and creates a custom class for you. That's handy, but I passed on it. For one thing, I haven't heard that there's a VS 2008 version of this. Additionally, I don't like to require a custom add-in in order to get my code to work in case I want to add a new profile property - especially when I'm working on a project that's going to be distributed on CodePlex.

Fortunately, it's not very hard to implement a custom profile. First, we'll write a class that inherits from System.Web.Profile.ProfileBase. I added a few static accessors, too:

using System.Web.Profile;
using System.Web.Security;

namespace VideoShow
{
    public class UserProfile : ProfileBase
    {
        public static UserProfile GetUserProfile(string username)
        {
            return Create(username) as UserProfile;
        }

public static UserProfile GetUserProfile() { return Create(Membership.GetUser().UserName) as UserProfile; } [SettingsAllowAnonymous(false)] public string Description { get { return base["Description"] as string; } set { base["Description"] = value; } } [SettingsAllowAnonymous(false)] public string Location { get { return base["Location"] as string; } set { base["Location"] = value; } } [SettingsAllowAnonymous(false)] public string FavoriteMovie { get { return base["FavoriteMovie"] as string; } set { base["FavoriteMovie"] = value; } } } }

 
Now we need to  hook that up in the profile section of web.config - notice that I've included inherits="VideoShow.UserProfile" in the profile declaration:
 
<profile inherits="VideoShow.UserProfile">
  <providers>
    <clear />
    <add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="VideoShowConnectionString"/>
  </providers>
</profile>
 
With that done, I can grab an instance of the custom profile class and set a property:
 
//Write to a user profile from a textbox value
UserProfile profile = UserProfile.GetUserProfile(currentUser.UserName);
profile.FavoriteMovie = FavoriteMovie.Text;
profile.Save();

Part of the reason for the accessor is to allow display of profile information for users other than the current user - for instance, a public profile page which displays information about other users in the system.

//Write to a user profile from a textbox value
UserProfile profile = UserProfile.GetUserProfile(displayUser.UserName);
Response.Write(profile.FavoriteMovie)

And of course, I can still databind to it as well:

<span id="user-favorite-movie"><%= VideoShow.UserProfile.GetUserProfile().FavoriteMovie %></span>

A few disclaimers:

  • This isn't news, it's been out since ASP.NET 2.0 shipped. Still, it's pretty handy to know about, and if you're like me you may have forgotten or never really dug into some of the ASP.NET 2.0 goodies.
  • This isn't the ultimate solution in terms of entity modeling. Custom profile information is stored in two columns in the aspnet_Profile table (delimited strings in one column, another column for binary serialized objects). That means that the only real way to read or write custom property values is via the profile API. That's not a real problem unless you need to query or join on information stored in a custom profile setting.

Further information:

Profiles in ASP.NET (K. Scott Allen)

Essential ASP.NET 2.0, Chapter 5 (Fritz Onion)

Published Saturday, January 19, 2008 11:46 PM by Jon Galloway
Filed under:

Comments

# re: Writing a custom ASP.NET Profile class

Thanks for this. Saved me a lot of pain trying to figure out why it wouldn't work in my Web Application Project. Hopefully I'll get it going in a web service I'm putting together too.

Tuesday, March 11, 2008 6:01 AM by Matt

# re: Writing a custom ASP.NET Profile class

And here's a tip that may save you another hour  of pain ;)

Make sure that the name of the property you create matches the base property you try to return i.e. don't do this:

[SettingsAllowAnonymous(false)]

public string UserAge

{

 get { return base["Age"] as string; }

 set { base["Age"] = value; }

}

Otherwise it will complain with

"The settings property 'Age' was not found."

Change 'Age' to 'UserAge' and it will work.

Tuesday, March 11, 2008 8:22 AM by Matt

# re: Writing a custom ASP.NET Profile class

Can someone tell me how to translate the first two functions to VB.NET ? would be great.

Thanks!

Tuesday, March 11, 2008 10:55 AM by uquandux

# re: Writing a custom ASP.NET Profile class

Thanks!!  This really helped, plus helps reduce the opacity of the profile provider for future re-factoring.  I second Mr Baldman's posts - be sure to remove any <properties/> elements from the web.config file.

Tuesday, March 11, 2008 3:48 PM by Liatris

# re: Writing a custom ASP.NET Profile class

Thanks for this code Jon.

I've implemented it easily in my site and it works great, but have you been able to unit test it?  On my first attempt, the inherited "Create" method returned a DefaultProfile object, which caused a casting failure.  I figured out that the Unit Tests were not using the web.config file to see the custom Profile Provider I configured, then I figured out you need to copy the web.config to the unit test project, and rename it to app.config.  However now I get the error.  

"Test method TestMyProject.UserControllerTest.CreateNewUserTest threw exception:  System.TypeLoadException: Could not load type 'MyRootNamespace.Profile.UserProfile' from assembly 'System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.."

I don't know why it is not looking the DLL that contains my custom "UserProfile" class.  Any ideas?  It works in my website, but not in the Unit Test.  The UnitTest project references the project containing the Profile class.  I'm using VS2008 built-in Unit Testing.

Thanks in advance.

Tuesday, March 25, 2008 3:58 PM by Scott Davis

# re: Writing a custom ASP.NET Profile class

Anyone have any ideas about Scott's post above?

I am also trying to unit test the custom profile class. Any ideas?

Thanks,

Tim

Thursday, April 10, 2008 4:29 PM by Tim

# re: Writing a custom ASP.NET Profile class

hei .... can anyone please help me ?

I am trying to implement the custom profile class... so far so good... it just doesn't retrieve any info at all :(

i have added this in my web.config

<profile inherits="UserProfile">

     <providers>

       <clear />

       <add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="LocalSqlServer"/>

     </providers>

   </profile>

and my UserProfile class is very much like the one above....

did anyone else experience this problem ?

thanks in advance ...

andu

Tuesday, April 15, 2008 9:45 PM by andu

# re: Writing a custom ASP.NET Profile class

Thanks for saving me a ton of time!

Great article!

Best,

Brett

Monday, May 26, 2008 12:21 AM by Brett Nieland

# re: Writing a custom ASP.NET Profile class

How would you handle groupings using this method?

Thanks!

Brett

Monday, May 26, 2008 1:14 AM by Brett Nieland

# re: Writing a custom ASP.NET Profile class

I am facing the same issue as Scott and Tim above. I've posted about it on the forums:

forums.asp.net/.../2397754.aspx

Tuesday, June 3, 2008 10:44 AM by PMichaud

# re: Writing a custom ASP.NET Profile class

I echo Brett's question.  How in the heck do you handle grouping properties?  I've tried Googling to no avail.

Wednesday, June 18, 2008 9:41 AM by Jamie Cross

# re: Writing a custom ASP.NET Profile class

So will it automatically grab the related value from the profile table or a class is needed to do that job? I am little confused

Monday, June 23, 2008 2:11 PM by MH

# re: Writing a custom ASP.NET Profile class

So will it automatically grab the related value from the profile table or a class is needed to do that job? I am little confused.

Thursday, June 26, 2008 1:10 PM by MH

# re: Writing a custom ASP.NET Profile class

UserProfile profile = UserProfile.GetUserProfile(displayUser.UserName);

Giving null object.

how to resove it?

Wednesday, August 13, 2008 5:48 AM by Savvy

# re: Writing a custom ASP.NET Profile class

I'm Getting this problem on a Web Application. It's running on the website. Any Ideas?

Thursday, August 28, 2008 2:25 PM by ofern01

# re: Writing a custom ASP.NET Profile class

Thanks Martin Bayly for CustomProviderData howto use mention!

Saturday, August 30, 2008 8:53 PM by Roman

# re: Writing a custom ASP.NET Profile class

Thx for your explanation. It helped me a lot.

Wednesday, September 3, 2008 8:54 AM by Xavier

# re: Writing a custom ASP.NET Profile class

Awesome! Thanks for this code Jon.

I've implemented it easily in my site and it works great. Thanks for saving me a ton of time. It helped me a lot.

Wednesday, October 22, 2008 3:50 PM by Thomas Drago

# re: Writing a custom ASP.NET Profile class

Is it possible to set a property as "[SettingsAllowAnonymous(true)]" and get the profile for an anonymous user?

I have been trying to do this but I am not able.

Could someone, please, help me out?

Friday, November 14, 2008 3:17 PM by shapper

# re: Writing a custom ASP.NET Profile class

How in the heck do you handle grouping properties in the class? Was anyone able to find the answer, if so could you please post it.

Thursday, November 20, 2008 9:44 AM by drs

# re: Writing a custom ASP.NET Profile class

I was able to answer my own question. What I did was i used a demo website project and setup my profile properties and groups in the webconfig so that it would autogenerate the class into Asp.Net Temporary files and then looked at how the code got generated for the groups.

Thursday, November 20, 2008 3:09 PM by drs

# re: Writing a custom ASP.NET Profile class

Did anyone figure out how to get a custom profile class with groups to work with the SqlStoredProcedureProfileProvider? I can't get it to pick up my groups

Sunday, November 23, 2008 1:47 PM by dsteinle

# re: Writing a custom ASP.NET Profile class

DRS, can you post an example of the group code?

Monday, November 24, 2008 7:23 PM by Andrew

# re: Writing a custom ASP.NET Profile class

I'm also unable to get profile groups to work with the custom profile class. Has anyone played around with attributes of the <profile> tag to see if there's some "secret" setting that causes a  ProfileGroup to get recognized by ASP.NET and included in the custom object that it generates?

Saturday, December 13, 2008 5:34 PM by Jim Black

# re: Writing a custom ASP.NET Profile class

Can this profile type be accessed for a winform, is so how?

Monday, January 12, 2009 2:30 AM by Mike

# re: Writing a custom ASP.NET Profile class

Thanks, Jon. You just saved my sanity.

Friday, January 16, 2009 9:32 AM by Michael Earls

# re: Writing a custom ASP.NET Profile class

UserProfile profile = UserProfile.GetUserProfile(displayUser.UserName);

Giving null object. because Unable to cast object of type 'ProfileCommon' to type 'UserProfile'.

how to resove it?

thanks

Saturday, February 21, 2009 1:24 AM by Amir

# re: Writing a custom ASP.NET Profile class

Has anyone developed a solutin to the null object problem that several people asked about? I implemented this custome profile provider exactly as shown but keep getting a null profile back. The UserProfile.Save() does not appear to be saving at all. Any help?

Friday, June 12, 2009 12:29 PM by James

# re: Writing a custom ASP.NET Profile class

If you want to retreive values from your DB you have to specify defaultProvider in profile section of your config file. When this is the case you will have user profile data in object.

Cheers

Tuesday, July 7, 2009 10:14 AM by Joksa

# re: Writing a custom ASP.NET Profile class

After looking for days to figure out why i was getting null objects, why I was getting identical assemblies, and why this simple setup would not work I have the answer.

1. for identical assembly errors remove your global application class if you have one. I have no clue why on earth this would cause an error but it does.

2. casting (UserProfile)Create(username) will not run if the casting operation doesn't work. and the Create(UserName) as (UserProfile) will return a null if the casting operation doesn't work. Because you should be able to perform a cast at this point you should not get any errors.

The problem is because your web pages are still maintained as a web project not a web application project. This formality has the undoe consequence of creating a ProfileCommon class then trying to cast to it. This creates an invalid cast or null whatever have you. Simply right click your project and tell it to convert to web application. The system will no longer build a profileCommon class and you should be able to now cast the profilebase to a userprofile type.

It's amazing how the tiny things always slip by.

Friday, July 17, 2009 2:44 PM by Thomas

# re: Writing a custom ASP.NET Profile class

I'm banging my head against the wall here.  I created the class for the profile and it works fine in my Web App. But I have a compiled DLL that I want to access the profile data as well and all I can get is "Object reference not set to an instance of an object." when I try to access the profile.

The compiled DLL can access CONNECTIONSTRINGS and APPSETTINGS from the web.config but not the profile.  

What am I missing?

Monday, July 27, 2009 8:31 AM by Bill

# re: Writing a custom ASP.NET Profile class

Following Thomas's advice I have got it to work only with one minor alternation - It converts my App_Code folder into Old_App_Code - but on doing so it works. Any solutions on how to get this to leave App_Code as App_Code?

Tuesday, August 11, 2009 8:00 AM by Malachi

# re: Writing a custom ASP.NET Profile class

Hi, i'm using this property

[SettingsAllowAnonymous(false)]

       public Dictionnary<string,string> ClientLayoutData

       {

           get { return base["ClientLayoutData"] as string; }

           set { base["ClientLayoutData"] = value; }

       }

when i save the profile, i'm getting ... is not supported because it impelemts idictionary.

help ?

Monday, January 11, 2010 4:41 AM by Holger

# re: Writing a custom ASP.NET Profile class

Isn't

 Dictionnary<string,string> != string

the problem?

Monday, January 18, 2010 7:30 PM by void

# re: Writing a custom ASP.NET Profile class

A fantastic post that saved me some time, just wanted to add, that if you are unit testing or using a custom profile class in console applications and the class lives in a separate assembly, say a code library project in the same solution.  make sure that you tell it the partial assembly name with means the profile element in the config file changes to:

profile inherits="namespace.namespace.className, assemblyName"  

other wise the app freaks out and says it can't find the class in assembly System.Web or something nonsensical like that

Tuesday, March 2, 2010 1:36 PM by mattha

# re: Writing a custom ASP.NET Profile class

I keep getting the following error when running the application:

CS0234: The type or namespace name 'UserProfile' does not exist in the namespace 'AgileApp' (are you missing an assembly reference?)

I have the following in my web.config file:

<profile inherits="AgileApp.UserProfile">

The namespace in the UserProfile class is set to AgileApp.  Am I missing something?

Tuesday, March 9, 2010 10:58 PM by Casey

# re: Writing a custom ASP.NET Profile class

ok so i have my profiles working and i've even added a photo.  so how do i allow users to creat their own page and display it for people like myspace or other community sites?  is this called serialization or something like that?  thanks for your help!

dvdgzzrll@msn.com

Thursday, March 25, 2010 2:08 PM by David

# re: Writing a custom ASP.NET Profile class

You saved my day.  (Maybe I lacked some search skills here, but I just could not find proper help on this one)

Implemented in the Krok Asp.Net MVC Template Project.

Monday, May 31, 2010 10:25 AM by krokonoster

# re: Writing a custom ASP.NET Profile class

to resolve this error

Unable to cast object of type 'System.Web.Profile.DefaultProfile' to type

MyNameSpace.AccountProfile

1.  Right click on project, Convert to Web Application

2.   In your web.config, make sure you use the "inherits" attribute to use your custom class

<profile inherits="MyNameSpace.AccountProfile">

<providers>

<clear/>

<add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" connectionStringName="MyConnectionString" applicationName="/"/>

</providers>

</profile>

Friday, August 20, 2010 7:24 PM by Craig

# re: Writing a custom ASP.NET Profile class

Readers may also be interested in this solution:

Using the SQL Table Profile Provider in ASP.NET 4 Web Applications (C# & VB)

weblogs.asp.net/.../using-the-sql-table-profile-provider-in-asp-net-4-web-applications-c-amp-vb.aspx

Sunday, September 5, 2010 9:53 PM by Ken Cox [MVP]

# re: Writing a custom ASP.NET Profile class

Thanks! After a day of searching, this was the first article I found with a workable solution on using the Profile  class in a Web Application Project. I followed your instructions and it works, even on my GoDaddy hosted asp.net site.

Friday, September 17, 2010 3:49 PM by cyberidian

# re: Writing a custom ASP.NET Profile class

This seems to work for simple Strings, but I can't get it to work for complex types.  I am trying to persist a shopping cart, to a the database, but it's not working as expected

Tuesday, December 14, 2010 6:25 PM by Ross

# re: Writing a custom ASP.NET Profile class

Heya,

I figured it out.  I was using an IList, and the compiler was having trouble serializing it.  Changed it to a List and all is good.

Ross

Tuesday, December 14, 2010 9:11 PM by Ross

# re: Writing a custom ASP.NET Profile class

Hi All,

Firstly, a HUGE thanks to Jon (and other contributors) on helping with creating the custom Profile. This was a problem that I encountered while migrating our ASP.Net web site to Azure platform, which I need to convert into a web application.

Anyway, I had a problem where I would create a UserProfile instance by:

UserProfile profile = UserProfile.GetUserProfile();

This would always create me a new ProfileCommon, so it does not keep the profile properties whenever I set or get it. I have managed to resolve this by casting the HttpContext.Current.Profile instead, and that works a treat.

e.g. ((UserProfile)HttpContext.Current.Profile).<myProfileSetting>

Keep up the good work, brilliant article.

Many Thanks - Jay

Thursday, March 24, 2011 5:46 AM by Jay Man

# re: Writing a custom ASP.NET Profile class

Thank You!!!

I've been trying to find a clear explanation of how to implement this for hours.

This works like a charm!

Friday, September 2, 2011 1:09 PM by bkuhn

# re: Writing a custom ASP.NET Profile class

How does ProfileCommon get created in the web site projects ?   Does it require a code generator to add the properties to a generated module?

Or can you just use the Create method and get a profile with the web.config properties recognized ? ?  I think the properties are in a collection in this class.

If you add properties to your own custom class...do the inherited methods from PofileBase work ? Save? GetProperty? SetProperty?

Wednesday, September 21, 2011 12:53 PM by chris9876

# re: Writing a custom ASP.NET Profile class

UserProfile CLASS:

Namespace MIDASProfileManager

   Public Class UserProfile

       Inherits ProfileBase

       Public Shared Function GetUserProfile(username As String) As UserProfile

           Return TryCast(Create(username), UserProfile)

       End Function

       Public Shared Function GetUserProfile() As UserProfile

           Return TryCast(Create(Membership.GetUser().UserName), UserProfile)

       End Function

       <SettingsAllowAnonymous(False)> _

       Public Property Theme() As System.String

           Get

               Return DirectCast(MyBase.Item("Theme"), String)

           End Get

           Set(value As System.String)

               MyBase.Item("Theme") = value

           End Set

       End Property

       <SettingsAllowAnonymous(False)> _

       Public Property ThemeSelectedIndex() As Integer

           Get

               Return DirectCast(MyBase.Item("ThemeSelectedIndex"), Integer)

           End Get

           Set(value As Integer)

               MyBase.Item("ThemeSelectedIndex") = value

           End Set

       End Property

   End Class

End Namespace

Web.Config:

   <profile inherits="MIDAS.MIDASProfileManager.UserProfile" enabled="true" defaultProvider="MyAspNetSqlProfileProvider" >

     <providers>

       <add name="MyAspNetSqlProfileProvider"

            connectionStringName="aspnetdbConnectionString"

               applicationName="MIDAS"

               type="System.Web.Profile.SqlProfileProvider" />

     </providers>

   </profile>

In Global.asax Session_Start:

       Dim Profile As UserProfile = UserProfile.GetUserProfile(SV.Username)

       SV.ddTheme = Profile.Theme

       SV.ddThemeSelectedIndex = Profile.ThemeSelectedIndex

My SV Class:

Imports MIDAS.MIDASProfileManager

''' <summary>

''' Session variables class - provides a facade to the ASP.Net Session Object.

''' All access to Session variables must be through this class.

''' Create an instance, populate and store in Session object for each session.

''' </summary>

Public NotInheritable Class SV

   Public Shared ReadOnly Property Username As String

       Get

           Return HttpContext.Current.User.Identity.Name

       End Get

   End Property

   Public Shared Property ddTheme As String

       Get

           If HttpContext.Current.Session("ddTheme") Is Nothing Then

               Return GV.DefaultTheme

           Else

               Return CStr(HttpContext.Current.Session("ddTheme"))

           End If

       End Get

       Set(ByVal value As String)

           If CStr(HttpContext.Current.Session("ddTheme")) = value Then

               Return

           End If

           ' TODO: To change to also store in profile

           HttpContext.Current.Session("ddTheme") = value

           Dim Profile As UserProfile = UserProfile.GetUserProfile(SV.Username)

           Profile.Theme = value

           Profile.Save()

       End Set

   End Property

   Public Shared Property ddThemeSelectedIndex As Integer

       Get

           If HttpContext.Current.Session("ddThemeSelectedIndex") Is Nothing Then

               Return GV.DefaultThemeSelectedIndex

           Else

               Return CInt(HttpContext.Current.Session("ddThemeSelectedIndex"))

           End If

       End Get

       Set(ByVal value As Integer)

           If CInt(HttpContext.Current.Session("ddThemeSelectedIndex")) = value Then

               Return

           End If

           ' TODO: To change to also store in profile

           HttpContext.Current.Session("ddThemeSelectedIndex") = value

           Dim Profile As UserProfile = UserProfile.GetUserProfile(SV.Username)

           Profile.ThemeSelectedIndex = value

           Profile.Save()

       End Set

   End Property

End Class

My GV Class:

Imports System.Data

Imports System.Linq

Imports System.Web

Imports Microsoft.Practices.EnterpriseLibrary.Logging

''' <summary>

''' Contains my site's global variables.

''' </summary>

Public NotInheritable Class GV

   Private Sub New()

   End Sub

   Public Shared Property DefaultTheme() As String

   Public Shared Property DefaultThemeSelectedIndex() As Integer

End Class

Global.asax Application_Start has:

           GV.DefaultTheme = System.Configuration.ConfigurationManager.AppSettings("DefaultTheme")

           GV.DefaultThemeSelectedIndex = CInt(System.Configuration.ConfigurationManager.AppSettings("DefaultThemeSelectedIndex"))

Friday, February 3, 2012 7:53 PM by Raja Lakshman

# re: Writing a custom ASP.NET Profile class

Ive put your userprofile class in the App_Code Folder of my web app project + the inherits code into web.config.

I still cant access the user profiles class in any of my code behind files.

Tuesday, February 21, 2012 12:17 AM by Warren

# re: Writing a custom ASP.NET Profile class

Jon,

How would one add a Profile property to a basepage based on your UserProfile class having functionality for both getprofile() and getprofile(username)? Thnx in advance, a.

Saturday, July 14, 2012 9:46 AM by Alexander Hoevenaars

# re: Writing a custom ASP.NET Profile class

this works file in local, if hosted it in server it showing error.

<profile inherits="Admin.UserProfile">

ERROR: The type or namespace name 'Admin' could not be found (are you missing a using directive or an assembly reference?)

this works fine in :www.mywebsite.com, showing error in www.mywebsite.com/admin.

i have subfolder called admin and i'm using this userinfo class in main directory,if access it like /admin it showing above error.

I'm working with mvc3 in main directory and webpage(aspx) in /admin folder.

Tuesday, July 31, 2012 9:38 AM by tirumalesh

# re: Writing a custom ASP.NET Profile class

this works file in local, if hosted it in server it showing error.

<profile inherits="Admin.UserProfile">

ERROR: The type or namespace name 'Admin' could not be found (are you missing a using directive or an assembly reference?)

this works fine in :www.mywebsite.com, showing error in www.mywebsite.com/admin.

i have subfolder called admin and i'm using this userinfo class in main directory,if access it like /admin it showing above error.

I'm working with mvc3 in main directory and webpage(aspx) in /admin folder.

Tuesday, July 31, 2012 9:38 AM by tirumalesh

# re: Writing a custom ASP.NET Profile class

Perfact code. specially web.config entries.

Friday, December 28, 2012 7:26 AM by Manibhadra

# re: Writing a custom ASP.NET Profile class

Running VS2012 with ASP.NET 4.5 with Web Forms Application I ran into the same problem (still..)

You saved my day!

Wednesday, February 6, 2013 5:17 AM by Barry

# re: Writing a custom ASP.NET Profile class

Thanks in support of sharing such a fastidious idea, piece

of writing is nice, thats why i have read it entirely

Tuesday, April 2, 2013 3:35 PM by Pace

# re: Writing a custom ASP.NET Profile class

Just a tip for anyone else who runs into this problem, I ran into pretty much the same thing Andu described: I was able to implement everything fine, but when I'd do a lookup on a custom property, it would always return an empty string.  Turns out I was missing the attribute [CustomProviderData("propertyName;SqlDbType")] for each field in the Profile subclass.  After that, worked like a champ.  

This is an older blog post, but really helped me in porting over an old app, thanks, much appreciated.

Thursday, May 9, 2013 10:08 AM by Jason Sheridan