Click here to Skip to main content
15,883,883 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am working on Asp.net with the c# project. Here I have a requirement, Open the same window with multiple pages with multiple Sessions.

Example:

1) MainPage.aspx which is Parent window. Which have multiple orders.

2) ChildPage.aspx which is child window

The customer can open different machines by selecting different orders. So always open a ChildPage.aspxpage with different data(Order values).

So, for these requirements which method I should use and Why?

What I have tried:

I tried using Sessions, which is not working for me.
Posted
Updated 17-Jul-18 23:39pm
Comments
F-ES Sitecore 13-Jul-18 6:42am    
I don't really understand the question, but you can't control session management from your code so you can't force them to use multiple sessions, or even the same session...that all depends on how the user's browser handles cookies.

So if sessions don't work then use querystrings, it's a no-brainer. Only thing to bear in mind if that the querystring can be manipulated by the user so if this is sensitive data make sure the person asking for the data has the rights to see it.
Bojjaiah 13-Jul-18 6:52am    
The customer can open the ChildPage.aspx page after selecting any of records. Again customer can open ChildPage.aspx page by selecting another record from MainPage.aspx. Here ChildPage.aspx are multiple windows for every request. In this case, the session will not work, right? So, how can we handle in this situation?

Use view states / hidden fields.

ASP.NET View State Overview[^]
 
Share this answer
 
You use the session or View state

For view state use:
Understanding ASP.NET View State[^] this link follow
Viewstate is use in only one page

For session use:
ASP.NET Session State Overview[^]
session is use server side and client side
 
Share this answer
 
You use the session or View state

More suitable for Your Question in use to View state.

For view state use:
Understanding ASP.NET View State[^] this link follow
Viewstate is use in only one page

For session use:
ASP.NET Session State Overview[^]
session is use server side and client side
 
Share this answer
 
Hi,

Even tought you can achive your goal with one way or another, here is what and how i think you should use sessions and queryStrings.

1/ QuerySTrings
-I always use queryString to redirect to details pages.
In your case childWindow.aspx?id=5.
As long the data you pass is not important (no password and other critical data)
=> thats why you must have an id column in your database tables, so you can get your data with your unique ids.
2/Session:
Session can make the code very hard to mantain, so its better to avoid them and only use them when needed.
3/ViewStates
View states are basicaly sessions but not in all of the application level but in the page level.
They are very usefull in postbacks.
Here is an exemple :
private MyClass ClassObject
        {
            get { return ViewState["myClassObj"] as MyClass ; }
            set { ViewState["myClassObj"] = value; }
        }

You can imagine this as an init, when a post back is performed, you can always access your ClassObject because we saved it.

PS : Pay attention, with this method any user can change the value in the url and access data they dont have the right to, so :
-You should implement a role management system to avoid this.
-Probably wise to encrypt/decrypt your queryStrings.

Hope it helps.
 
Share this answer
 

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