Friday, October 11, 2013

Working with Profile in web applications

The last time I worked with Profiles was back on the days we were creating web sites. Recently I had to add support for profiles in an old school asp.net web application. I tried to remember what I was doing back in the days, and I finally figured out that the code generation feature of Profile does not work in web application (only web sites). This means that you have to manually to the casting from
HttpContext.Current.Profile.GetPropertyValue and even worse you have to call a SetPropertyValue method to set the Profile property which is really ugly! The good news is that you can still use the inherits property of the Profile configuration and set your own class, instead of specifying the properties inside the web.config.

Here is a fast implementation I did to wrap up the whole functionality:

No comments: