I am trying to add AD Authentication to a existing Intranet Aplication,
The Application uses Form Authentication at the moment.
My Web Application works Correctly but when i go to Login.aspx page this error comes on:
System.InvalidCastException: 'Unable to cast object of type 'System.Security.Principal.GenericIdentity' to type 'System.Web.Security.FormsIdentity'.'
System.InvalidCastException occurred
HResult=0x80004002
Message=Unable to cast object of type 'System.Security.Principal.GenericIdentity' to type 'System.Web.Security.FormsIdentity'.
Source=App_Web_dusai4r1
StackTrace:
at Account_Login.Page_Load(Object sender, EventArgs e) in C:\Users\d_rody\Desktop\BlueStone.1old\WebSites\BlueStone\Account\Login.aspx.cs:line 16
The code i am using :
The code i am using :
FormsIdentity id = (FormsIdentity)User.Identity;
FormsAuthenticationTicket ticket = id.Ticket;
Response.Write("TicketName: " + ticket.Name);
Response.Write("
Cookie Path: " + ticket.CookiePath);
Cookie Path: " + ticket.CookiePath);
Response.Write("
Ticket Expiration: " +
Ticket Expiration: " +
ticket.Expiration.ToString());
Response.Write("
Expired: " + ticket.Expired.ToString());
Expired: " + ticket.Expired.ToString());
Response.Write("
Persistent: " + ticket.IsPersistent.ToString());
Persistent: " + ticket.IsPersistent.ToString());
Response.Write("
IssueDate: " + ticket.IssueDate.ToString());
IssueDate: " + ticket.IssueDate.ToString());
Response.Write("
UserData: " + ticket.UserData);
UserData: " + ticket.UserData);
Response.Write("
Version: " + ticket.Version.ToString());
Version: " + ticket.Version.ToString());
Also I am not a .Net expert, so any help will be greatly appreciated.
1 Reply
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Vignesh ManiPosted May 2, 2017, 7:22 AM