Log user in

Discussion in 'ASP .Net' started by Andrew Banks, Apr 7, 2004.

  1. Andrew Banks

    Andrew Banks Guest

    Using forms authentication in C# I usually use
    FormsAuthentication.RedirectFromLoginPage to log a user in as follows

    FormsAuthentication.RedirectFromLoginPage(id,false);

    How can I log a user in without re-directing them somewhere else? I simply
    want to log the in and then run some other code without re-directing them.

    I've tried .SetAuthCookie(id,false) but this doesn't seem to work.

    Any ideas?
    Andrew Banks, Apr 7, 2004
    #1
    1. Advertising

  2. SetAuthCookie will set an Auth cookie for the next request, i.e. cookie will
    be sent with the response. This way you can't use User.Identity to get an
    information about just logged in user without receiving a new request with
    the new Auth cookie just set - you need to use your own mechanism.

    "Andrew Banks" <> wrote in message
    news:ACUcc.4827$...
    > Using forms authentication in C# I usually use
    > FormsAuthentication.RedirectFromLoginPage to log a user in as follows
    >
    > FormsAuthentication.RedirectFromLoginPage(id,false);
    >
    > How can I log a user in without re-directing them somewhere else? I simply
    > want to log the in and then run some other code without re-directing them.
    >
    > I've tried .SetAuthCookie(id,false) but this doesn't seem to work.
    >
    > Any ideas?
    >
    >
    Viktor Jevdokimov, Apr 7, 2004
    #2
    1. Advertising

  3. Andrew Banks

    Andrew Banks Guest

    Sorry Viktor, I don't fully understand what you are saying.

    Can anyone give an example of how I can log a user in without using
    RedirectFromLoginPage?

    Thanks

    "Viktor Jevdokimov" <> wrote in message
    news:...
    > SetAuthCookie will set an Auth cookie for the next request, i.e. cookie

    will
    > be sent with the response. This way you can't use User.Identity to get an
    > information about just logged in user without receiving a new request with
    > the new Auth cookie just set - you need to use your own mechanism.
    >
    > "Andrew Banks" <> wrote in message
    > news:ACUcc.4827$...
    > > Using forms authentication in C# I usually use
    > > FormsAuthentication.RedirectFromLoginPage to log a user in as follows
    > >
    > > FormsAuthentication.RedirectFromLoginPage(id,false);
    > >
    > > How can I log a user in without re-directing them somewhere else? I

    simply
    > > want to log the in and then run some other code without re-directing

    them.
    > >
    > > I've tried .SetAuthCookie(id,false) but this doesn't seem to work.
    > >
    > > Any ideas?
    > >
    > >

    >
    >
    Andrew Banks, Apr 7, 2004
    #3
  4. OK, I have a login form with the login button. In the LoginButton_Click
    event handler method I validate user name and password in the DB. If
    validation is successfult, I have this line of code for example:


    System.Web.Security.FormsAuthentication.SetAuthCookie(strUserName, False,
    "/")

    "/" is the cookie path.
    Below this line I have the code I need, and finally, a redirect, since my
    controls and pagest looking for a Page.User.Identity, which will be changed
    ONLY with the next request, since current request was without authentication
    cookie you just set with "SetAuthCookie". What else?

    What I'm saying, you have to know, how your application performs a request
    step by step, and is it possible to use a request context to put an
    authentication info (user name, etc) on the context, and check it somewhere
    in your application, instead of Page.User.Identity...

    Finally, how can you determine, that "SetAuthCookie" is not working?


    "Andrew Banks" <> wrote in message
    news:Yi%cc.5155$...
    > Sorry Viktor, I don't fully understand what you are saying.
    >
    > Can anyone give an example of how I can log a user in without using
    > RedirectFromLoginPage?
    >
    > Thanks
    >
    > "Viktor Jevdokimov" <> wrote in message
    > news:...
    > > SetAuthCookie will set an Auth cookie for the next request, i.e. cookie

    > will
    > > be sent with the response. This way you can't use User.Identity to get

    an
    > > information about just logged in user without receiving a new request

    with
    > > the new Auth cookie just set - you need to use your own mechanism.
    > >
    > > "Andrew Banks" <> wrote in message
    > > news:ACUcc.4827$...
    > > > Using forms authentication in C# I usually use
    > > > FormsAuthentication.RedirectFromLoginPage to log a user in as follows
    > > >
    > > > FormsAuthentication.RedirectFromLoginPage(id,false);
    > > >
    > > > How can I log a user in without re-directing them somewhere else? I

    > simply
    > > > want to log the in and then run some other code without re-directing

    > them.
    > > >
    > > > I've tried .SetAuthCookie(id,false) but this doesn't seem to work.
    > > >
    > > > Any ideas?
    > > >
    > > >

    > >
    > >

    >
    >
    Viktor Jevdokimov, Apr 8, 2004
    #4
    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. Henrik_the_boss
    Replies:
    0
    Views:
    2,647
    Henrik_the_boss
    Nov 5, 2003
  2. Amratash
    Replies:
    0
    Views:
    518
    Amratash
    Apr 13, 2004
  3. =?Utf-8?B?VG9tIFdpbmdlcnQ=?=

    My.Log.Writeexception not writing to Application Event Log.

    =?Utf-8?B?VG9tIFdpbmdlcnQ=?=, Jan 20, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    2,370
    =?Utf-8?B?VG9tIFdpbmdlcnQ=?=
    Jan 20, 2006
  4. unomystEz
    Replies:
    0
    Views:
    548
    unomystEz
    Nov 19, 2006
  5. vj
    Replies:
    0
    Views:
    678
Loading...

Share This Page