ProfileBase.UserName and forms auth via the Login control

K

Keith Patrick

Currently, if I declare an asp:Login control on a page and login, on both
OnAuthenticate and OnLoggedIn, this.Profile.UserName is still null, even
though the user does get authenticated and shows up as such on the main
page. However, I have to set some profile values as soon as the user logs
in, but because those events still are within the scope of the "anonymous"
profile, I can't access the profile for the user that logged in. Is what
I'm trying to do possible, and if so, at what point do I get the current
user's profile?
 
K

Keith Patrick

FYI: after redoing my search terms, I found a solution (and explanation)
from when the thing was called HttpProfileBase:

Profiles are handled by an HttpModule. By the time OnLoggedIn (OT, but the
Login/Logout ASP vs. FXCop duelling standards is driving me nuts) is called,
the profile module has already executed for this request, so the profile
can't be updated *after* login/logon, unless you manually do it. So here's
the code to do so:
ProfileBase profile = ProfileBase.Create(this.Logon.UserName,
true);
profile["MyProp"] = "MyValue";
profile.Save(); // This is necessary even with
automaticSaveEnabled because the module won't re-run to check IsDirty
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top