Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Security > Unable to cast object of type 'System.Security.Principal.GenericIdentity' to type 'System.Web.Security.FormsIdentity'.

Reply
Thread Tools

Unable to cast object of type 'System.Security.Principal.GenericIdentity' to type 'System.Web.Security.FormsIdentity'.

 
 
kroyce@ups.edu
Guest
Posts: n/a
 
      05-01-2007
I completed the How To on using Forms Authentication with Active
Directory and am receiving an error when casting Current.User to
FormsIdentity object. I can't find my error nor can I find anything
through Google, MSDN or KB on the issue. This leads me to believe it
is my issue and I need some help if at all possible. The error
message I receive is:

Unable to cast object of type
'System.Security.Principal.GenericIdentity' to type
'System.Web.Security.FormsIdentity'.

My c# code looks like the following and I am using ASP.Net 2.0:
lblName.Text = "Hello " + Context.User.Identity.Name + ".";
lblAuthType.Text = "You were authenticated using " +
Context.User.Identity.AuthenticationType + ".";
FormsIdentity id =
(FormsIdentity)HttpContext.Current.User.Identity;
FormsAuthenticationTicket ticket = id.Ticket;
lblCookieUserName.Text = ticket.Name;
lblCookieData.Text = ticket.UserData;

Context.User.Identity.Name works great as does
Context.User.Identity.AuthenticationType.

The offending piece of code is:
FormsIdentity id =
(FormsIdentity)HttpContext.Current.User.Identity;

Any help or insight that you can provide would be very much
appreciated.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Unable to cast object of type 'System.Byte[]' to type 'System.String'. Imran Aziz ASP .Net 4 01-19-2011 03:39 AM
Unable to cast object of type 'ASP.main_master' to type 'ASP.main_master'. craigkenisston@hotmail.com ASP .Net 2 08-15-2006 11:23 PM
Unable to cast object of type 'asp.usercontrols_....._ascx' to type 'usercontrols_.....' marshausk@hotmail.com ASP .Net 1 08-14-2006 12:41 PM
Help: Unable to cast object of type 'System.Int32' to type 'System.String'. keithb ASP .Net 3 05-07-2006 08:06 AM
Unable to cast object of type 'ASP.' to type '' hlyall1189@gmail.com ASP .Net 0 04-11-2006 08:01 PM



Advertisments