如何在 C# 中通过 SessionID 获取会话 [英] How do I get a session by SessionID in C#

查看:143
本文介绍了如何在 C# 中通过 SessionID 获取会话的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个 ASP.NET MVC 应用程序,我正在尝试使用Uploadify"JQuery 插件.我遇到的一个问题是,在使用 Flash(uploadify 使用)发送 cookie 信息方面显然存在一个众所周知的错误.因此,在使用uploadify上传文件时,我尝试将身份验证令牌和会话ID与我的请求一起发送.这很棒,因为我可以确定某人是否已获得授权,但我似乎无法获得会话,因此无法访问会话变量.如果我有 SessionID,有没有办法在 C# 中获取 Session?

I'm working on an ASP.NET MVC app and I'm trying to use the 'Uploadify' JQuery plugin. One issue I'm running into is that there is apparently a well known bug in regards to sending up cookie information with Flash (which uploadify utilizes). So I've tried sending the auth token and the session id with my request when uploading a file using uploadify. This is great in that I can figure out if someone is authorized, but I can't seem to get the session and thus do not have access to session variables. If I have the SessionID, is there a way to get the Session in C#?

推荐答案

Session["myVar"] = "1234";
<%= this.Session.SessionID %>

HttpContext.Session.SessionID

请注意,您可以获得会话 ID,但您需要将内容存储在临时数据中,否则它会不断为您提供新 ID.

Note that you can get the session ID, but you need to store things in the temp data or it will keep giving you new IDs.

这篇文章有答案

这篇关于如何在 C# 中通过 SessionID 获取会话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆