Connecting Tech Pros Worldwide Help | Site Map

FormsAuthenticationTicket looses UserData

dev648237923
Guest
 
Posts: n/a
#1: Dec 1 '06
Upon logon I create a ticket and put some userdata in it:
FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(
3, //Version
tUsername.Text, //Username
DateTime.Now, //Issue time
DateTime.Now.AddHours(1), //Expires every hour
false, //Don't persist cookie
"test data" //User_SecureID
);
//Hash the cookie for transport
string hash = FormsAuthentication.Encrypt(ticket);
cookie = new HttpCookie( FormsAuthentication.FormsCookieName, hash);
Response.Cookies.Add(cookie);

***Later on another aspx page I want to read that userdata but it alweays is
empty???
if (HttpContext.Current.User != null)
{

if (HttpContext.Current.User.Identity.IsAuthenticated )
{
if (HttpContext.Current.User.Identity is FormsIdentity)
{
FormsIdentity id = (FormsIdentity)HttpContext.Current.User.Identity;
FormsAuthenticationTicket ticket = id.Ticket;
string userData = ticket.UserData;
}
}
}

Any ideas on fixing this greatly appretiated!


Walter Wang [MSFT]
Guest
 
Posts: n/a
#2: Dec 4 '06

re: FormsAuthenticationTicket looses UserData


Hi,

I created a simple web site using your code and it seems working correctly
on my side. I simply put the ticket creation code in login.aspx and in
default.aspx I can read the cookie's userData correctly.

Could you please confirm this also doesn't work on your side using a simple
web site? or maybe it's an environment specific issue.

Would you please create a more complete reproducible project and send it to
me? Thanks.


Sincerely,
Walter Wang (wawang@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications. If you are using Outlook Express, please make sure you clear the
check box "Tools/Options/Read: Get 300 headers at a time" to see your reply
promptly.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

dev648237923
Guest
 
Posts: n/a
#3: Dec 5 '06

re: FormsAuthenticationTicket looses UserData


Hi --

I also was able to get a simple project working so I think it must be an
environmental issue on this project. I will investigate further and post if
I find out what caused it. Thank you for you help and confirming tha the
code I am using is correct!

"Walter Wang [MSFT]" <wawang@online.microsoft.comwrote in message
news:Qt4F0a2FHHA.2304@TK2MSFTNGHUB02.phx.gbl...
Quote:
Hi,
>
I created a simple web site using your code and it seems working correctly
on my side. I simply put the ticket creation code in login.aspx and in
default.aspx I can read the cookie's userData correctly.
>
Could you please confirm this also doesn't work on your side using a
simple
web site? or maybe it's an environment specific issue.
>
Would you please create a more complete reproducible project and send it
to
me? Thanks.
>
>
Sincerely,
Walter Wang (wawang@online.microsoft.com, remove 'online.')
Microsoft Online Community Support
>
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications. If you are using Outlook Express, please make sure you clear the
check box "Tools/Options/Read: Get 300 headers at a time" to see your
reply
promptly.
>
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================
>
This posting is provided "AS IS" with no warranties, and confers no
rights.
>

Walter Wang [MSFT]
Guest
 
Posts: n/a
#4: Dec 6 '06

re: FormsAuthenticationTicket looses UserData


Hi,

Thanks for the follow-up. I'll be standing by when you find further
information on this issue.


Regards,
Walter Wang (wawang@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

Dan Ignatov
Guest
 
Posts: n/a
#5: Jan 15 '07

re: FormsAuthenticationTicket looses UserData


This helped me (.Net 2.0 + IIS 6):

http://www.derkeiler.com/Newsgroups/...4-02/0232.html

From http://www.developmentnow.com/g/8_20...s-UserData.htm

Posted via DevelopmentNow.com Groups
http://www.developmentnow.com
Closed Thread