Cast exception w FormsAuthentication

Ask a Question related to ASP.NET Security, Design and Development.

  1. #1

    Default Cast exception w FormsAuthentication

    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 Guest

  2. Similar Questions and Discussions

    1. #32101 [Com]: Exception in unknown on line 0 when throwing exception inside exception handler
      ID: 32101 Comment by: dhopkins at DonHopkins dot com Reported By: ceefour at gauldong dot net Status: No...
    2. #36840 [Asn->Csd]: Memory leak if cast operator throws an exception that is caught
      ID: 36840 Updated by: tony2001@php.net Reported By: andrei@php.net -Status: Assigned +Status: Closed Bug Type: Scripting...
    3. cast members moved in cast - neet to get htem back!!!
      Hello I inadvertedly pasted a cast member into my cast and it bumped the rest of the members one number forward, screwing up my lingo all over the...
    4. invalid cast exception with XmlSerializer
      I have the following web method in which I fill a typed dataset : ))] public XmlDataDocument GetEmployeesTypedXML() {...
    5. Please help on Specified cast is not valid exception
      Hi there! Does anybody know how to override GetWebRequest Method when using WSE on reference.cs. I get a "Specified cast is not valid...
  3. #2

    Default Re: Cast exception w FormsAuthentication

    Make sure you are casing the proper unary expression:

    ....((FormsIdentity)(User.Identity)).Ticket.UserDa ta;

    --
    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" <phewwee@yahoo.com> wrote in message
    news:%23c0aV$ClDHA.1960@TK2MSFTNGP12.phx.gbl...
    > 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 Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139