Cast exception w FormsAuthentication

Discussion in 'ASP .Net Security' started by news.microsoft.com, Oct 16, 2003.

  1. I have a small ASPX app I have created and decided to roll my own Forms
    Authentication. Now I take the user name, password and domain and created an
    encrypted foms authentication ticket. In the ticket I put some info in the
    userdata property. On a different page after authetication I want to accsess
    that field. I found a couple of examples, one is like
    lblLogin.Text = ((FormsIdentity)User.Identity).Ticket.UserData;

    This throws an exception saying cast is not valid. I've looked at this where
    the GenericPrincipal is created in the Globalasax file and I can see the
    string data in the UserData, does anyone have any idea?
     
    news.microsoft.com, Oct 16, 2003
    #1
    1. Advertising

  2. Make sure you are casing the proper unary expression:

    ....((FormsIdentity)(User.Identity)).Ticket.UserData;

    --
    Chris Jackson
    Software Engineer
    Microsoft MVP - Windows XP
    Windows XP Associate Expert
    --
    More people read the newsgroups than read my email.
    Reply to the newsgroup for a faster response.
    (Control-G using Outlook Express)
    --

    "news.microsoft.com" <> wrote in message
    news:%23c0aV$...
    > I have a small ASPX app I have created and decided to roll my own Forms
    > Authentication. Now I take the user name, password and domain and created

    an
    > encrypted foms authentication ticket. In the ticket I put some info in the
    > userdata property. On a different page after authetication I want to

    accsess
    > that field. I found a couple of examples, one is like
    > lblLogin.Text = ((FormsIdentity)User.Identity).Ticket.UserData;
    >
    > This throws an exception saying cast is not valid. I've looked at this

    where
    > the GenericPrincipal is created in the Globalasax file and I can see the
    > string data in the UserData, does anyone have any idea?
    >
    >
     
    Chris Jackson, Oct 17, 2003
    #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. VB Programmer

    Question: Invalid Cast Exception Error

    VB Programmer, Oct 28, 2003, in forum: ASP .Net
    Replies:
    4
    Views:
    1,362
    VB Programmer
    Oct 28, 2003
  2. Mark Olbert
    Replies:
    2
    Views:
    578
    Mark Olbert
    Dec 5, 2003
  3. MSG

    to cast or not to cast malloc ?

    MSG, Feb 6, 2004, in forum: C Programming
    Replies:
    38
    Views:
    1,079
    Dan Pop
    Feb 10, 2004
  4. EvilRix
    Replies:
    8
    Views:
    648
    Martin Dickopp
    Feb 14, 2004
  5. Pavel
    Replies:
    7
    Views:
    535
    Pavel
    Sep 19, 2010
Loading...

Share This Page