Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.Net: If I have the Session ID, Can I get the Session object?

This question is related to this one, though I think I was a little too long-winded there to really get a good answer. I'll keep this brief.

I'm working on a web handler (ashx) that accepts a form post from an aspx page. When the handler receives this form post, in order to do what it needs to do, it needs to know the user who is logged in (User.Identity.Name), but I can't rely on cookies being sent by the browser.

I know I can get the Session.SessionID and place it in a hidden form field, but once my handler receives the form post, how can I use that SessionID to figure out the logged-in user's identity?

I'm using the StateServer mode for session state.

like image 349
Josh Hinman Avatar asked Sep 11 '08 00:09

Josh Hinman


2 Answers

I think you can do it be implementing the IReadOnlySessionState interface on your HttpHandler

like image 79
lomaxx Avatar answered Oct 24 '22 19:10

lomaxx


Jonas posted a great answer to this question here:

Can I put an ASP.Net session ID in a hidden form field?

like image 36
Josh Hinman Avatar answered Oct 24 '22 17:10

Josh Hinman