Thursday, November 15, 2007

Web Parts Personalization Providers

As I say in my previous post, today I found a lot of problems when I deploy my application in an integration environment.

Web Parts Personalization was a problem, because I can't use the default database to store the personalization values.

We found two posible solutions in this links:
http://msdn2.microsoft.com/en-us/library/aa479037.aspx
http://www.kowitz.net/files/source/XmlFilePersonalizationProvider.cs.txt

First of two, allow to store values in a txt file and second allow to store values in an XML files.

Both examples, build a class that derives from ProviderBase class. I use txt file provider, I customize the class, because I need more functionality. For example, I implemented this method that recognize when a user has personalization data:

public override int GetCountOfState(PersonalizationScope scope,
PersonalizationStateQuery query)
{
if (File.Exists(GetPath(query.UsernameToMatch, query.PathToMatch)))
return 1;
else
return 0;
}


It works ok and now, I don't need the default personalization database.

No comments: