Frinavale 9,735
Recognized Expert Moderator Expert
One of the most fundamental topics in web design is understanding how to pass information collected on one web page to another web page. There are many different ways you could do this: Cookies, Database... However, I'm going to cover how to use Sessions.
Sessions are used to store information in order to use it during later page requests or in other web pages in a web application. By default Cookies are used to identify which session belongs to which browser. There is an option that you can set in your web.config file to use Cookieless Sessions; however you should keep in mind that for most web applications the Session ID should be kept private and when using Cookieless Sessions the Session ID is displayed in the query string.
In .NET there are three session states: InProc, StateServer, and SQLServer.
By default web applications are set up to use InProc. Where are Sessions stored? InProc
The session is kept as live objects on web server (aspnet_wp.exe) . It is stored in memory and is the fastest out of the three options; however, you should keep in mind that the more data you store in session, the more memory on the web server is consumed. This could affect the performance of your applications running on the web server. Also keep in mind that you cannot use InProc sessions in a web garden for many reasons I'm not going to get into. StateServer
The session is serialized and stored in memory in a separate process (aspnet_state.e xe). State Server can run on another machine, whereas InProc is specific to the machine the website is running on. You should keep in mind that the cost of serialization/deserialization of the session can affect performance if you're storing lots of objects. SQLServer
The session is serialized and stored in a table in an SQL server. It requires you have a database available and you should think about how you are going to secure the connection to the database. This is the slowest of the three options but is required in order to store persistent data. How do I use Sessions in my web application
It's really quite simple.
In the following example I use VB.NET to store the text value (userName) of a text box in session during a button click: -
Private Sub btn_button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_button1.Click
-
Session("userName") = txt_userName.Text
-
End Sub
-
In the following example I use VB.NET to display the text value (userName) stored session. This can be used on another web page within the web application: -
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
-
Dim userName as String = Session("userName")
-
lbl_welcome.Text= "Welcome to working with Sessions " + userName + "!"
-
End Sub
-
May 9 '07
13 35986 Frinavale 9,735
Recognized Expert Moderator Expert
i am aware of 1st 4 types u explaied including viewstate. but i have 1 doubt.
hiddenfield n hiddenframe r wh exactly , r they related to viewstate or something different, can u explain hiddenfield n hiddenframe more
ViewState is used to remember the state of your ASP.NET controls.
Hidden Fields are html that hold temporary information for the page...it remembers information but not necessarily about an ASP.NET Control.
Hidden fields can be used to pass information between JavaScript and your .NET code. Eg. your JavaScript function does something and then stores the result into a hidden field, this filed can then be accessed by the server side code to do further calculations.
-Frinny
Hi Frinavale, thanks for this info.
i had a doubt, i have i multiple users who would be accessing different records at the same time.
and if im using Session to pass the values as required, could this result in a slow performance for my web app. also is there any way to remove a session after the value is passed..
would this affect another user if his command(button click) tries to create the session again with the same name?
Frinavale 9,735
Recognized Expert Moderator Expert
If you have several users then you, and you are storing a lot of information in session, then you run the risk of using a lot of memory resources on the server computer. If you use more memory than is allocated to your website, then the web application process will be recycled.
I'm not sure about the effects of speed performance Session will have on your application; however, it is much faster than accessing a database every request. (Likewise storing things in ASP.NET's Cache is even faster).
Do some tests to determine what is best for your solution.
-Frinny
Thanks u sir i have don it.... love this forum
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Carlo Marchesoni |
last post by:
Ideally I would be able to give my aspx/ascx pages to a
designer which makes them nice and since I'm, using code-
behind he will not destroy my code.
But unfortunately he says that this format (aspx) is not
recognized by FrontPage - is there another tool that
designers like and allows to work directly on aspx
pages ?
|
by: Paul |
last post by:
What I am trying to do is as follows.
I have a page with 3 links,that direct the user to 3 different pages when selected after login.
So all link selections will first direct the user to a login page. Once the user logs in then they are directed to the appropriate link.
So for all 3 links they all go to a login page, but each link must pass information to the login in page, specifically the page to go to after login takes place.
--
Paul G...
|
by: hugo.flores |
last post by:
Hello all.
I want to know what would be the best way to pass information between
pages in ASP.NET? Querystring, seession variables, server transfer?
If possible if anyone can list advantages/disadvantages of each, or any
good/bad experience using one against the others.
Thanks
|
by: Marcelo |
last post by:
Any suggestion?
Thanks
Marcelo
|
by: Robert Leroux |
last post by:
Hello,
I'm new at this part of vb.net development, but I am trying to find a
way that I can take information that is contained in my asp page on my
web server and pass that information to my vb.net form? I'm not sure
where to begin at this stage. The only thing I can see, is that when
my asp page code parses the information that I need, I'll need to write
that information to a database or a file then have something in my
vb.net...
| |
by: sesling |
last post by:
I have created a query that will pull information from our database for the operators. This query will pull in on average 50,000 records. The operators need to refine the search results. I have used the following in the criteria section of the query for the operators to refine the search . However, the operators do not always remember how the clients name appears in the DB and we get several failed queries. To correct this, I created a form...
|
by: czuvich |
last post by:
I am working in ASP.NET 1.1 and I was wondering if it was possible to
have two different windows pass information between each other by the
click of say a button. In other words, let's say I have Window A and
Window B. A is the main application and opens a popup window called B.
I then have a button in B that needs to pass control back to Window A
with some data in the URL and then close itself. Is this possible? If
so.. how?
|
by: Joseph Basil |
last post by:
Hello ,
i am using lots of session in my projecct.therefore it affects the speed of the project .so can anyone hrlp me to transfer datas between pages without using session.pls help.
regards,
joseph
|
by: raylopez99 |
last post by:
Keywords: scope resolution, passing classes between parent and child
forms, parameter constructor method, normal constructor, default
constructor, forward reference, sharing classes between forms.
Here is a newbie mistake that I found myself doing (as a newbie), and
that even a master programmer, the guru of this forum, Jon Skeet,
missed! (He knows this I'm sure, but just didn't think this was my
problem; LOL, I am needling him)
If...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |