System.Web.HttpContext.Current.Session["dbname"] System.Web.HttpContext.Current.Session["dbname"]使用此方法读取session 多个用户登陆的时候 后面用户登陆后也显示的是第一个用户的信息。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 注销用户可以将session销毁 我有笨方法,建个表,用session记录后插到表里,然后下一个登陆用户显示直接读表里的数据。 直接使用Session["dbname"],取得父类Page.Session属性应该能取得本页的session 直接读取本页的Session吧,如果是在Page类及其派生类中。 Cookie和Session是与特定用户相关的,不会出现这种情况的,是不是你的代码有些问题。 看lz取session的方式应该是在非web文件里取session吧应该是存session的时候出的问题吧 帮忙看一下代码:public Dbconn() { connectionstring = System.Web.HttpContext.Current.Session["dbname"].ToString() scn = new SqlConnection(); scn.ConnectionString = connectionstring; }红色的代码就是我要取的session值。 connectionstring 怎么用session呢?难道你不同用户对应不同的connectionstring?否则的话,你最好把它写到webconfig中. 你得在登录的时候给Session["dbname"]赋值啊, 建议public Dbconn(string connectionstring) { //connectionstring = System.Web.HttpContext.Current.Session["dbname"].ToString() scn = new SqlConnection(); scn.ConnectionString = connectionstring; } 将connectionstring传入。HttpContext.Current 是一个静态变量,整个进程中只有一份copy,因此肯定是最后一个给它赋的值了.Page.Session是本页面request的session. 建议你将connectionstring从page的继承类中传到你的函数中。 请教个.net中关于权限访问问题! 在线急等中 页面绑定DataRowView,并做判断.这一句应该怎么写? 如何增加我的帐号的可用分??? open()时怎样去掉标题栏上的网页地址. 请问关于日历控件的问题,请大家帮忙 >>>>>>大虾帮忙看下AJAX在iis6中不起作用的问题<<<<<===== Com组件中返回的集合对象Collection怎么方便的与服务器控件绑定? 求解javascript中的变量问题! 送分了,怎样加确认? 现在快速开发工具还有前景吗 为什么要用Get Set,有何好处? asp.net怎样上传视频?(C#)
{
connectionstring = System.Web.HttpContext.Current.Session["dbname"].ToString()
scn = new SqlConnection();
scn.ConnectionString = connectionstring;
}红色的代码就是我要取的session值。
否则的话,你最好把它写到webconfig中.
{
//connectionstring = System.Web.HttpContext.Current.Session["dbname"].ToString()
scn = new SqlConnection();
scn.ConnectionString = connectionstring;
} 将connectionstring传入。HttpContext.Current 是一个静态变量,整个进程中只有一份copy,因此肯定是最后一个给它赋的值了.Page.Session是本页面request的session. 建议你将connectionstring从page的继承类中传到你的函数中。