question: Disappearing Sessions Dear AllI'm having some trouble using session variables to store a users username and password. In theory these will be used everytime a page needs to query an oracle database.I also use the variables in response.write() lines so that I can see the variables on pages as I move around. The trouble is that the variables appear to be disappearing. At present I'm writing the aspx pages and hence I'm viewing the pages in a browser constantly refreshing pages to view my changes.When a page is loaded for the first time the query to the database is made without an issue. However when I refresh the page a couple of minutes later (session timeout is set to 30 mins) I get an erro message saying I used an invalid username/password (ORA: 01017). If I take out the query from the page and rely on looking at my variables as displayed using the response.write () statements, there are no values held.It appears that when I login the session variables are created and then read when I load another page for the first time, as soon as I refresh a page the variables appear to be destroyed. Is this right? I would expect the variables to survive after refreshing the page.
Answer 1: Your session variables should survive multiple trips to the site just fine (although they will time out after 30 minutes).Are you making any changes to the code between trips from the browser? Note that anytime the application restarts your session variables will be lost -- so it could be that you are touching a web.config file, making a change in code or doing something else that causes the application to be restarted.Hope this helps,
Answer 2: As I read your question it was unclear if you'd created session vars. They are specific constructs that must be establish within your code. exampleDim critter As String critter = "Bird" Sessiong("MyCritter") = critterIn this example it would be likely that given the circumstances you describe that critter would return a null while the sessiong var MyCritter would still hold the word Bird. Are you setting the session vars in this manner?
再把timeout改大一些
还有要在控制面版的服务中把ASP.NET State Service启动
但改为mode="StateServer"后Session是很稳定的
不管我设置session的超时时间为多长 ,session总是很快就超时了
感觉Session and Cookie both 挺神秘的东西
有时确实搞不懂
-----------------------------------------------------
天才是能问出好问题的人!
建议使用Csdn的做法,同时使用Cookie和Session,如果Session丢失了就用Cookie再生成一个Session,因为Cookie是存储在客户端的,所以相对比较稳定。
但是要注意加密噢。
就是
window.open('A.aspx?param1=值,param2=值,...','');再另外一个窗口用Request的属性来取值,具体是哪个记不清楚了这样就不会丢失了.也不存在Session的问题了
再把timeout改大一些
还有要在控制面版的服务中把ASP.NET State Service启动以按上述设置,仍出现丢失。企盼高人!!!
“
<sessionState mode="InProc" stateConnectionString="tcpip=127.0.0.1:42424" sqlConnectionString="data source=127.0.0.1;Trusted_Connection=yes" cookieless="false" timeout="20"/>”
设置其中的cookieless为:cookieless="true"
------------------------
如果
把 <sessionState mode="InProc" 改为<sessionState mode="StateServer"
把timeout改大一些
把ASP.NET State Service启动但不限制站点的物理内存/虚拟内存及站点的连结数服务器会不挂掉了?
Session.Abandon(); //取消当前会话
------------------------------------
SESSION丢失时间不固定,怎么使用:Session.Abandon()?
Disappearing Sessions
Dear AllI'm having some trouble using session variables to store a users username and password. In theory these will be used everytime a page needs to query an oracle database.I also use the variables in response.write() lines so that I can see the variables on pages as I move around. The trouble is that the variables appear to be disappearing. At present I'm writing the aspx pages and hence I'm viewing the pages in a browser constantly refreshing pages to view my changes.When a page is loaded for the first time the query to the database is made without an issue. However when I refresh the page a couple of minutes later (session timeout is set to 30 mins) I get an erro message saying I used an invalid username/password (ORA: 01017). If I take out the query from the page and rely on looking at my variables as displayed using the response.write () statements, there are no values held.It appears that when I login the session variables are created and then read when I load another page for the first time, as soon as I refresh a page the variables appear to be destroyed. Is this right? I would expect the variables to survive after refreshing the page.
Your session variables should survive multiple trips to the site just fine (although they will time out after 30 minutes).Are you making any changes to the code between trips from the browser? Note that anytime the application restarts your session variables will be lost -- so it could be that you are touching a web.config file, making a change in code or doing something else that causes the application to be restarted.Hope this helps,
As I read your question it was unclear if you'd created session vars. They are specific constructs that must be establish within your code. exampleDim critter As String
critter = "Bird"
Sessiong("MyCritter") = critterIn this example it would be likely that given the circumstances you describe that critter would return a null while the sessiong var MyCritter would still hold the word Bird. Are you setting the session vars in this manner?
不过你们所说的和ie有关啊什么打开窗口的方法不同阿还有什么window.close相关之类的问题那基本上是不可能的哈动动脑子session在服务器端关ie什么事情哟
建议楼主要传大数据,用viewstate(本页面),跨页面的用临时表
也许是ie认为新开了一个线程,可能是ie的bug