如何在多个页面中进行会话 [英] how to mentain session in multiple pages

查看:61
本文介绍了如何在多个页面中进行会话的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请一些人告诉我如何在多个页面中管理会话。



就像我将会话值从一个页面发送到另一个页面那么它会起作用但是如果我想访问另一个第三页,然后它显示错误。



请一些人告诉我如何使用不同的页面访问会话值,比如我想要访问会话值4-5页。

Pls some one tell that how to manage session in multiple pages.

like if i send session value from one page to another page then it will work but if i want to access another third page then it show the error.

pls some one tell that how to access session value with different pages like i want to access session value with 4-5 pages.

推荐答案

如果您创建一个会话,那么整个应用程序都可以访问该会话。这意味着你所有的页面都可以毫无问题地访问它,除非你没有删除或终止会话。



所以,检查你的代码并找出哪个bug在某处杀死你的会话。



1. ASP.NET会话状态概述 [ ^ ]

2. 在ASP.NET中探索会话 [ ^ ]
If you create one Session, then that will be accessible throughout the application. That means all you pages could access it without any issues, unless you don't delete or kill the Session.

So, review your code and find out the bug which is killing your Session somewhere.

1. ASP.NET Session State Overview[^]
2. Exploring Session in ASP.NET[^]


您好朋友,请注意会话不是任何页面特定对象,而是存储在服务器中。因此,如果在会话对象中保留任何值,则可以从应用程序中的任何页面访问该值,直到会话过期。



例如,在一个有100页的应用程序中。任何会话对象都可以从所有页面访问。



Hello friend, please note that session is not any page specific object, rather it's stored in the server. So, if you keep any value in a session object, that value can be accessed from any page with in the application until the session is expired.

For example, there in an application with 100 pages. Any session object will be accessible from all pages.

// Storing value in session object
Session["Name"] = "Chander Rani";

// Retrieving value from session object
string name = Session["Name"].ToString();



注意:在访问任何会话对象之前进行空检查是最佳做法。



我建议你通过一些与Session对象相关的在线教程。希望这会有所帮助。


Note: It's a best practice to have a null check before accessing any session object.

I would suggest you to go through some online tutorials relates to Session object. Hope that would be helpful.


这篇关于如何在多个页面中进行会话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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