Best Regards
XiaoYong Dai
Microsoft Online Community Support
Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
LearningCSha...
Member
1 Points
3 Posts
Unable to cast object of type 'System.Security.Principal.GenericIdentity' to type 'System.Web.Sec...
May 24, 2007 06:52 PM|LINK
Hi
Has anyone ever came across this problem before, the code was working ok this morning, but now it not and nothing has changed.
Here is some test code
string UserData = Ret.ToString();
okiesTicket);okie);
ToString();
FormsAuthenticationTicket objTestForCookiesTicket;
HttpCookie objTestForCookiesCookie;
objTestForCookiesTicket = new FormsAuthenticationTicket(1,
strEmail,
DateTime.Now,
DateTime.Now.AddMinutes(120),
true,
UserData);
objTestForCookiesCookie = new HttpCookie(".ASPXAUTH");
objTestForCookiesCookie.Value = FormsAuthentication.Encrypt(objTestForCo
objTestForCookiesCookie.Expires = objTestForCookiesTicket.Expiration;
Response.Cookies.Add(objTestForCookiesCo
Response.Redirect("Test.aspx");
############
string CartID;
protected void Page_Load(object sender, EventArgs e)
{
FormsIdentity objTestForCookiesCookie;
objTestForCookiesCookie = (FormsIdentity)User.Identity;
CartID = objTestForCookiesCookie.Ticket.UserData.
Response.Write("Test " + " " + CartID);
}
Any help on this would be appreciated
George
XiaoYong Dai...
All-Star
38310 Points
4229 Posts
Re: Unable to cast object of type 'System.Security.Principal.GenericIdentity' to type 'System.Web...
May 28, 2007 06:15 AM|LINK
Hi
To get the FormsIdentity I feel you need to have been authenticated. This thread might help
http://forums.asp.net/p/917302/1044360.aspx#1044360
XiaoYong Dai
Microsoft Online Community Support
Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.