Click here to Skip to main content
15,902,939 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
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.
Posted
Comments
Nirav Prabtani 2-Jun-14 13:08pm    
what is problem??

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[^]
 
Share this answer
 
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.

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

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

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.
 
Share this answer
 
Comments
Hassaan_Malik 21-Mar-17 13:51pm    
But in that solution you will have to mention the destination page. Otherwise it will throw the null reference exception. Mean i session state you must have just one destination page.
Debabrata_Das 13-Apr-17 5:20am    
Sorry friend, but I'm unable to get your concern. Will you be able to rephrase your query or concern.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900