K
kroyce
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.
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.