Connecting Tech Pros Worldwide Help | Site Map

FormsAuthenticationTicket looses UserData

 
LinkBack Thread Tools Search this Thread
  #1  
Old December 1st, 2006, 05:05 PM
dev648237923
Guest
 
Posts: n/a
Default FormsAuthenticationTicket looses UserData

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!



  #2  
Old December 4th, 2006, 04:25 AM
Walter Wang [MSFT]
Guest
 
Posts: n/a
Default 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.

  #3  
Old December 5th, 2006, 12:25 PM
dev648237923
Guest
 
Posts: n/a
Default 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.
>

  #4  
Old December 6th, 2006, 12:35 AM
Walter Wang [MSFT]
Guest
 
Posts: n/a
Default 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.

  #5  
Old January 15th, 2007, 03:25 PM
Dan Ignatov
Guest
 
Posts: n/a
Default 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
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,662 network members.