I’m trying to use ASP.net profiles I’ve followed some instructions which means I have
- set up a the ASPNETDB (using SQLExpress 2005)
- configured the profile provider (in the web.config)
- defined some properties
- enabled authentication
But I can’t seem to use code like (ie Intellisense doesn’t like it)
Profile.UserCustomContent = "Hi Mom";
It’s obvious I’ve missed something major, but I cannot see, please help me…
Here are some snips from my web.config
<connectionStrings>
<add name="SqlServices"
connectionString="Data Source=localhost;Integrated Security=SSPI;Initial Catalogue=aspnetdb" />
</connectionStrings>
<system.web>
<authentication mode="Windows" />
<authorization>
<deny users="?"/>
</authorization>
<profile enabled="true" defaultProvider="SqlServices">
<providers>
<clear/>
<add name="SqlProvider" type="System.Web.Profile.SqlProfileProvider"
connectionStringName="SqlServices" applicationName="MyInternalApplication" />
</providers>
<properties>
<add name="UserSearchFilterOptions" type="String" />
<add name="UserCustomContent" type="String"/>
</properties>
</profile>
</system.web>
If you are using the Web Application Project, you will need to implement profiles yourself. Profiles only work out-of-the-box with the Web Site option. The Web Application Project does not have the Profile object automatically added to each page as with the Web Site project, so we cannot get strongly-typed programmatic access to the profile properties defined in our web.config file.
So, if you are using a Web Application Project, this should help:
http://code.msdn.microsoft.com/WebProfileBuilder
However, if you are using the Web Site Project, then this article from Scott Guthrie should lead you in the right direction:
http://weblogs.asp.net/scottgu/archive/2005/10/18/427754.aspx
More details on one of my own blog posts on this:
http://www.codersbarn.com/post/2008/06/01/ASPNET-Web-Site-versus-Web-Application-Project.aspx
🙂