Hello, in one of my apps that I support they are using Session[""] to store datatable information. Creatiing new datatables and storing in session and using that to share information across different pages.
They are using this to store information locally in the session for some time and then append more information the same datatable retirved from session and use to across pages.
When you cliked a button another window is opned on top the first window, so they are using this.
First of all I think there is no reason to open another window( isn't that bad practice?)
First of all, session variables have to be populated from somewhere. They may be hitting the database too many times to pull the data but there's nothing wrong with keeping a little in session. Personally, if it's static data, I'd cache it.
Secondly, web development isn't really a winforms practice. Is it bad practice to open a pop-up in a web form, yes and no. Most of the time, it is bad practice because it's bad design. It's tough to justify. Additinally, if it hijacks the thread so that
you can't flip between the pages, ok, it's a modal dialog, but no it shouldn't be an entirely new form.
You'll see this a lot in environments where the developers are primarily winforms developers and they're migrating to web. It's a hard habit to kick.
Sessions have expiration behavior. If expired app would be crashed. Popups widely used on today web applications. Problems is some browsers are block popups be default. But users like instant behavior rather than redirecting elsewhere.
Marked as answer by Allen Li - MSFT on Apr 26, 2012 03:21 AM
As far as i know we can not set not to expire. But we can increase the expiration time on IIS. Default is 20 Min. When the user browsing the application expiration time renewed automatically. Problem comes when the user loged and not using the app. But what
you can do is, add a script on html meta data to refresh the page on timely basis. Then request goes to the server and session will be renewed.
You can set session configuration in your web.config file like below
<sessionState
mode="InProc"
timeout="60"
/>
Here you can set your timeout in minutes to a larger value.
But this is not at all a good practice. Due to following reasons
Session values are stored in Worker Process memory in the web server. Imagine, If a user logs in and stores values into session and closes the browser window. The session still remains in the server memory, eating up server memory. Now if the same user
again logs into the application, its all together a new session. The values get stored again in server memory. If this happens with 100 users your web server memory will get over used and the server will stop reponding/give internal server errors etc. But
with session timeouts, the memory is release after the timeout time is elapsed
There are certain parameters on which IIS can be configured to recycle the worker process, and one of the is the memory usage. Now if the memory is a particular level IIS will recycle the worker process. This will cause all your Session Values to get lost.
Hope it helps you!
Cheers,
Gopakumar
| Please click “Mark as Answer” on the post(s) if it helps |
First of all I think there is no reason to open another window( isn't that bad practice?)
Could you anyone please explain this...
Maybe they want the previous page (Homepage maybe) to be displayed all the time.
Now regarding session, it is used to store information about a user in context who's currently accessing your system so that this piece of information is readily avaialbe in memory until user is active. So we would store this information in server memory,
hence would increase performace as we don't have to get it again and again from the database.But again once user logs out or is inactive this information is not atall required to be stored in server memory because server memory is limited and we don't need
this information often, so it's better to remove it from session.Hope you got the point.
nissan
Participant
1065 Points
618 Posts
Disadvantages for using Session[""]
Apr 19, 2012 02:01 PM|LINK
Hello, in one of my apps that I support they are using Session[""] to store datatable information. Creatiing new datatables and storing in session and using that to share information across different pages.
They are using this to store information locally in the session for some time and then append more information the same datatable retirved from session and use to across pages.
When you cliked a button another window is opned on top the first window, so they are using this.
First of all I think there is no reason to open another window( isn't that bad practice?)
Could you anyone please explain this...
adamturner34
Contributor
3964 Points
999 Posts
Re: Disadvantages for using Session[""]
Apr 19, 2012 04:33 PM|LINK
Well,
First of all, session variables have to be populated from somewhere. They may be hitting the database too many times to pull the data but there's nothing wrong with keeping a little in session. Personally, if it's static data, I'd cache it.
Secondly, web development isn't really a winforms practice. Is it bad practice to open a pop-up in a web form, yes and no. Most of the time, it is bad practice because it's bad design. It's tough to justify. Additinally, if it hijacks the thread so that you can't flip between the pages, ok, it's a modal dialog, but no it shouldn't be an entirely new form.
You'll see this a lot in environments where the developers are primarily winforms developers and they're migrating to web. It's a hard habit to kick.
cnranasinghe
Star
8885 Points
1798 Posts
Re: Disadvantages for using Session[""]
Apr 21, 2012 02:01 PM|LINK
Sessions have expiration behavior. If expired app would be crashed. Popups widely used on today web applications. Problems is some browsers are block popups be default. But users like instant behavior rather than redirecting elsewhere.
nissan
Participant
1065 Points
618 Posts
Re: Disadvantages for using Session[""]
Apr 23, 2012 01:49 PM|LINK
Regrading the expiration behaviour, can we set the expiration time not to expire?
cnranasinghe
Star
8885 Points
1798 Posts
Re: Disadvantages for using Session[""]
Apr 24, 2012 04:32 AM|LINK
Hi
As far as i know we can not set not to expire. But we can increase the expiration time on IIS. Default is 20 Min. When the user browsing the application expiration time renewed automatically. Problem comes when the user loged and not using the app. But what you can do is, add a script on html meta data to refresh the page on timely basis. Then request goes to the server and session will be renewed.
gopakumar.r
Participant
959 Points
193 Posts
Re: Disadvantages for using Session[""]
Apr 24, 2012 05:17 AM|LINK
You can set session configuration in your web.config file like below
Here you can set your timeout in minutes to a larger value.
But this is not at all a good practice. Due to following reasons
Hope it helps you!
Gopakumar
| Please click “Mark as Answer” on the post(s) if it helps |
nijhawan.sau...
All-Star
16432 Points
3174 Posts
Re: Disadvantages for using Session[""]
Apr 24, 2012 05:30 AM|LINK
Maybe they want the previous page (Homepage maybe) to be displayed all the time.
Now regarding session, it is used to store information about a user in context who's currently accessing your system so that this piece of information is readily avaialbe in memory until user is active. So we would store this information in server memory, hence would increase performace as we don't have to get it again and again from the database.But again once user logs out or is inactive this information is not atall required to be stored in server memory because server memory is limited and we don't need this information often, so it's better to remove it from session.Hope you got the point.