Last post Oct 01, 2018 08:28 AM by Gluups
Sep 28, 2018 03:00 PM|Gluups|LINK
I wrote a custom ProfileProvider, with which I could write a property with
? Context.Profile.SetPropertyValue("ZipCode", "54400")
and read it with
and it is permanent over sessions, but I am supposed to be able to access to it with
and Profile has no ZipCode property.
I presume I missed something while writing the profile provider.
Any idea what ?
Oct 01, 2018 02:01 AM|Nan Yu|LINK
Hi Gluups ,
If you are in web application , you cannot use Profile.item directly... the strongly-typed class is not magically generated for you from the Web.config file, so you have to roll your own. You have two choice :
1.Use the Web Profile Builder. This is a custom tool you add to Visual Studio which automatically generates the Profile object you need from your definition in Web.config.
2.Make your own class that derives from ProfileBase to represent your custom profile like your codes .
You can refer to below code sample for explanation and detail code sample :
Oct 01, 2018 08:28 AM|Gluups|LINK
Well I wrote a ProfileProvider, thank you. I must have missed something in it.
After that, some work remains to be done, as the example that I translated was based on a particular case, of a profile that contains a ZipCode and a stock object, and, curiously enough, creates a field per property in the ProfileData table.
So, I work on the webParts, and when I am done with it I shall come back to the profile provider and make it able to manage different properties given in the Web.config -and manage the exceptions.
Some documentation will be needed also I presume.
Well for the time being, I have got the contents of the existing properties, but with a heavy syntax. The question was how to get the zipcode with Profile.ZipCode
Oct 01, 2018 09:01 AM|Gluups|LINK
In fact yes, you gave me the answer, in Stackoverflow's page :
dynamic profile = System.Web.Profile.ProfileBase.Create(Context.User.Identity.Name);
string s = profile.ZipCode;
Dynamic profile was the key, and as you see I adapted the syntax for getting the user's name to initiate the profile.
Well, thank you very much.
I put that somewhere in the master page, maybe there is a better place to put that, for instance just after the login ?