ProfileBase.UserName and forms auth via the Login control

Discussion in 'ASP .Net' started by Keith Patrick, Dec 2, 2005.

  1. 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?
     
    Keith Patrick, Dec 2, 2005
    #1
    1. Advertising

  2. 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
     
    Keith Patrick, Dec 2, 2005
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?Q2hyaXMgTW9oYW4=?=

    Configuring Windows Auth & Forms Auth in Asp.Net

    =?Utf-8?B?Q2hyaXMgTW9oYW4=?=, Apr 28, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    742
    =?Utf-8?B?Q2hyaXMgTW9oYW4=?=
    Apr 28, 2004
  2. =?Utf-8?B?ZGhucml2ZXJzaWRl?=

    Windows Auth, but Forms Auth for one page?

    =?Utf-8?B?ZGhucml2ZXJzaWRl?=, Jan 8, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    600
    Elton Wang
    Jan 8, 2005
  3. Chris Mohan

    Configuring Windows Auth & Forms Auth in Asp.Net

    Chris Mohan, Apr 28, 2004, in forum: ASP .Net Security
    Replies:
    2
    Views:
    465
    Chris Mohan
    Apr 29, 2004
  4. Forms Auth Info passed to Windows Auth?

    , Apr 28, 2005, in forum: ASP .Net Security
    Replies:
    1
    Views:
    249
    Hernan de Lahitte
    May 3, 2005
  5. Ed Staffin
    Replies:
    1
    Views:
    393
    Ken Schaefer
    Apr 17, 2006
Loading...

Share This Page