The Differences in Profile between Web Application Projects (WAP) and website
The profile services is a very helpful and easy way to add custom properties for your users which is not contained in the Standard MembershipUser Properties...
for example , you may need to add the Marital status , Date of Birth, Address.... all of these are custom properties that you may need them while developing your projects ...
If you are familiar with Profile .. you will know that the first thing that must done when working with profiles is to set the Profile properties in web.config File ,
for example ,you can add the Date of Birth, address, Marital status for the user profile as follows,
<profile>
<properties >
<add name="DateOfBirth" type="DateTime"/>
<add name="Address" type="String"/>
<add name="MaritalStatus" type="String"/>
</properties>
</profile>
after saving the file , and working under a website project ,
you will notice that if you typed profile in the page code behind , you will see the properties generated for you as in the picture below:
this happened because the Visual studio created a new class called ProfileCommon Thats inherits ProfileBase , and adds the new properties to it ..
Note that visual studio will always update that class when you change the Profile properties in web.config ...
Now , if you are working with web application projects , you will notice that adding the Profile properties to web.config will not add any properties to Profile object in the code behind of the page.... this is because Visual studio doesn't generate a profileCommon class ...
instead you need to access the properties using ProfielBase.GetPropertyValue(PropertyName)
for example , to access the DateOfBirth property , you need to use this code
Dim DOB As DateTime = CDate(HttpContext.Current.Profile.GetPropertyValue("DateOfBirth"))
In this post , I talked about the Differences in Profile between the normal website and WAP projects , Note that there is a lot of other differences between them, for example ,
when working with resource files , the website will provide a strong typing for resources properties which is also handled by Visual studio ...
Regards,
Anas Ghanem