0

Possible Duplicate:
how to use Profile.GetProfile() in a library class?

How to get profile in a cs class? It works fine in aspx.cs class.

 ProfileCommon profile= HttpContext.Current.Profile.GetProfile(username);

How to make GetProfile() available in cs class? please advice, Thank you

Community
  • 1
  • 1
Benk
  • 1,284
  • 6
  • 33
  • 64

1 Answers1

0

Take a look at my answer about profiling users. There is all you need:

User profiles in asp.net

Community
  • 1
  • 1
Gregor Primar
  • 6,759
  • 2
  • 33
  • 46
  • in your code, you are creating a profile, how would I retrieve an existing profile? thanks – Benk Sep 29 '12 at 18:47
  • Take a look at my answer again. First you need to register profile provider and profile properties inside web.config. Create function creates profile or retrieves it if already exists. – Gregor Primar Sep 29 '12 at 18:51
  • In your case you are probably missing configuration or sqlProfile tables (if you are using SqlProfileProvider). – Gregor Primar Sep 29 '12 at 18:53
  • You are right. Thanks alot. Once I changed defaultProvider to SqlProvider It worked. Couple you please explain me the difference between AspNetSqlProfileProvider and SqlProvider, why it didnt work with AspNetSqlProfileProvider ? also in aspx.cs file I would use GetProfile() but in class file I use .ProfileBase.Create(), is it the same thing? Should I be using .ProfileBase.Create() in the aspx.cs file as well? thanks alot. – Benk Sep 29 '12 at 19:22
  • I dont think provider of type AspNetSqlProfileProvider exists. This is just a default name used for SqlProfileProvider. I guess you have mistyped yourself while altering web.config. When you want to access specific profile just use ProfileBase.Create("SomeUserName") and you will be on the safe side. Just ProfileBase.Create() will not give you a result you are looking for. – Gregor Primar Sep 29 '12 at 19:42