Raja Afrika of the Afrika 8
Sunday, December 22, 2024
 
Back to Raja's Blog

Raja's Blog
Not All Who Wander Are Lost

Profiling
Posted: Wednesday, May 21, 2008

So I decided to add profile support to my hobby music website www.RajaAfrika.com. I'd already added membership sometime back and when I discovered the ASP.NET Profile object I became very excited by the posibilities. Allowing anonymous and authenticated users to rate videos, select their favorite videos. Very cool!

It looks like you can access the profile object simply by type Profile. from your code behind. Here is where the problems began.

My code began to crap out immedietly. "Unable to connect to SQL Server." I figurered it was my enabling AnonymousAccess which you have to specify explicity. So I removed all references to the profile object for un-authenticated users. Still no dice.

So then I hit the internet. First DotNet247.com, then Google generally. I found a LOT of people encoutering the same problem. Looks like if you use SQL Express profiling works with no problem but if you are using a real SQL Server you run into problems. After about 6 or 7 hours of banging my head aginst the Internet I finally did my research where I should have in the first place MSDN.com. And in minutes I'd found the answer:

http://msdn.microsoft.com/en-us/library/system.web.profile.sqlprofileprovider.aspx

Looks like I had to run the RegSQL utility. Now I had already done this to instantiate membership on my target database but you have to RE-RUN it with the added option -A p to enable profile support on your membership database. YATAI! but not so fast. My code still bombed. What up with that.

Turns out there was a final step.
In my web.config I had to specify a SQL provider for th PROFILE node (see above link). Apparently it was not enough to have specified a SQL provider for the membership node. With that out of the way, profile support worked beautifuly with my SQL Server database.

Note: I'm not but if you use integrated authentication you have to create a SQL Login for the IIS_WPG account on your IIS machine and grant that Login relevant permissions on your membership database. I personally choose to to simply specify the username and password in my web.config connection string. much easier.

Cheers,
Martin
ps Happy video watching on www.RajaAfrika.com