<p>This question is related to <a href="https://stackoverflow.com/questions/43324/can-i-put-an-aspnet-session-id-in-a-hidden-form-field">this one</a>, though I think I was a little too long-winded there to really get a good answer. I'll keep this brief.</p>

<p>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.</p>

<p>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?</p>

<p>I'm using the StateServer mode for session state.</p>

[{'answer_id': 55609, 'author': 'lomaxx', 'author_id': 493, 'author_profile': 'https://Stackoverflow.com/users/493', 'pm_score': 2, 'selected': False, 'text': '<p>I think you can do it be implementing the <a href="http://www.hanselman.com/blog/GettingSessionStateInHttpHandlersASHXFiles.aspx" rel="nofollow noreferrer">IReadOnlySessionState</a> interface on your HttpHandler</p>\n'}, {'answer_id': 55651, 'author': 'Ben Scheirman', 'author_id': 3381, 'author_profile': 'https://Stackoverflow.com/users/3381', 'pm_score': 0, 'selected': False, 'text': '<p>In an HttpHandler or HttpModule implementation, you cannot always access session from the BeginRequest event.  There is another event you can handle, called OnAcquireRequestState.  If you write your code in that event, then HttpContext.Current.Session will not be null.</p>\n'}, {'answer_id': 55656, 'author': 'Adam Carr', 'author_id': 1405, 'author_profile': 'https://Stackoverflow.com/users/1405', 'pm_score': 1, 'selected': False, 'text': "<p>Unless there is a need to use session directly, you could always store whatever information about the logged-in user's identity in a singleton dictionary or cache and reference it via the SessionID stored in a hidden field.  I personally see security issues in this but won't go into those.  I would consider issuing single use identities for this type of implementation.</p>\n"}, {'answer_id': 240739, 'author': 'Josh Hinman', 'author_id': 2527, 'author_profile': 'https://Stackoverflow.com/users/2527', 'pm_score': 2, 'selected': True, 'text': '<p>Jonas posted a great answer to this question here:</p>\n\n<p><a href="https://stackoverflow.com/questions/43324/can-i-put-an-aspnet-session-id-in-a-hidden-form-field#237682">Can I put an ASP.Net session ID in a hidden form field?</a></p>\n'}]
['https://Stackoverflow.com/questions/55576', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/2527/']