views:

282

answers:

2

I have the following two profile properties in my web.config file between the System.Web tags:

<anonymousIdentification enabled="true"/>
<profile>
  <properties>
    <add name="CustomerName" allowAnonymous="true"/>
    <add name="CustomerID" allowAnonymous="true"/>
  </properties>
</profile>

When I try to access the Profile.CustomerName or Profile.CustomerID from an aspx.cs file, it doesn't show up. I thought when you create a custom profile property, it automatically updates the aspnetdb with the new properties. Profile doesn't show up in intellisense as well.

A: 

Hi, This problem occurs if you are creating a Web Application. Web Apps, unlike Websites, don't generate the ProfileCommon class. You could either follow this method: http://webproject.scottgu.com/CSharp/Migration2/Migration2.aspx (Appendix 2)

I haven't personally used the above assembly, so someone else might give some advice on that. However, you could also try:

Object customerName = HttpContext.Current.Profile.GetPropertyValue("CustomerName")

You won't get intellisense with this method, but as long as you know the property name, it can be accessed like that.

keyboardP
A: 

There is also a solution from Joel Spolsky here.

Jedidja