Forms Authentication - Really really basic question

Discussion in 'ASP .Net Security' started by LW, Apr 23, 2007.

  1. LW

    LW Guest

    Hello!
    I am just learning about forms authentication so please excuse this basic
    question. I am using .NET 1.1 and C#.

    I have created my web.config file and my login.aspx and the associated cs
    file using
    examples on MSDN. I have created a FormsAuthenticationTicket and cookie and
    added the cookie to the response and then set the SetAuthCookie etc. When I
    go to the redirected page, I am not sure how to read the cookie value so I
    know who the user is!

    In my FirstPage.aspx.cs's Page Load method, I have

    string userID = Request.Cookies[FormsAuthentication.FormsCookieName].Value;

    which is blank. My question is, once I read have created the ticket and
    cookie, how to I read it ? Most examples I am looking at talk about the
    creating tickets and cookies in forms authentication and not how to read the
    cookie so any help will be greatly appreciated. Do I need to decrypt the
    ticket?cookie?

    Thanks,
    LW, Apr 23, 2007
    #1
    1. Advertising

  2. On Apr 23, 8:40 pm, LW <> wrote:
    > Hello!
    > I am just learning about forms authentication so please excuse this basic
    > question. I am using .NET 1.1 and C#.
    >
    > I have created my web.config file and my login.aspx and the associated cs
    > file using
    > examples on MSDN. I have created a FormsAuthenticationTicket and cookie and
    > added the cookie to the response and then set the SetAuthCookie etc. When I
    > go to the redirected page, I am not sure how to read the cookie value so I
    > know who the user is!


    Once a user has authenticated, you can get it as

    Context.User.Identity.Name
    Alexey Smirnov, May 2, 2007
    #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. Brett Porter
    Replies:
    2
    Views:
    758
    Andrea D'Onofrio [MSFT]
    Jan 20, 2004
  2. Brett Porter
    Replies:
    5
    Views:
    586
    Brett Porter
    Feb 3, 2004
  3. Eric
    Replies:
    2
    Views:
    1,463
    Tommy
    Feb 13, 2004
  4. =?Utf-8?B?TFc=?=
    Replies:
    8
    Views:
    420
    =?Utf-8?B?TFc=?=
    Apr 25, 2007
  5. Brett Porter
    Replies:
    2
    Views:
    197
    Andrea D'Onofrio [MSFT]
    Jan 20, 2004
Loading...

Share This Page