spacer
spacer

Visual Basic & VB.NET resources | VBprofs.com

Google
 
Main Menu
Home
IT News
Articles
Source Codes
Books
Calendar of Events
Publish your Content
Links Directory
Reviews and Recs
Premium Content
 VBprofs Premium Content Become a member to get access to our premium content! 

 Membership is entirely free, and allows you to:
  •  access programming projects posted by our partners;
  •  publish your articles, news, links;
  •  publish a project request;
  •  access our VB Careers section.
Polls
How did you reach VBprofs.com?
  
Which is your favorite programming language?
  
Buy Text Link Ad
LinkWorth Stats
Check our stats on LinkWorth. If you like what you see, signup with LinkWorth and buy a link with us.
Related Items
 
Home arrow Articles arrow Visual Basic / .NET Articles arrow HOW-TO: Make sessions really work in .NET

HOW-TO: Make sessions really work in .NET PDF Print E-mail
Articles - Visual Basic / .NET Articles
Written by Hawkfield   
VB .NET articlesYou have sessions in every web based programming language. You have them in PHP, in ASP, and why would ASP.NET be any different. But ASP.NET has a better management of them, we explain how to take advantage.

Basically, a session is data that is kept over multiple requests for pages. A session was ussually stored on the server with a cookie, containing the session ID, on the client PC. ASP.NET is no different here, but there were several problems with this system.

First of all, the data would be stored on the server that made the request. If you happen to have multiple servers, serving the same user, the user had in fact 2 different sessions (one for each server). In ASP.NET, this can be solved in 2 ways. First of all you can store all the session information in an SQL server. 1 SQL server, serving multiple webservers, result in 1 session per user for all the servers. A second solution is the specifically designed StateServer. This server does nothing but keep track of user sessions (of course this can physically be the same machine as one of the webservers).

A second problem was the cookie sent to the client PC. Not all browsers support cookies, or the client has them turned off. This can also be easily solved in ASP.NET. It's as simple as changing 1 value in your applications Web.config.

The section in the Web.config responsible for all this is the section.

Here is what is possible in it:

mode="Off|InProc|StateServer|SQLServer"
cookieless="true|false"
timeout="# minutes"
stateConnectionString="tcpip=hostname:port"
sqlConnectionString="data source=hostname;user id=***;password=***" />

Mode
Off = No sessions
InProc = Standard, about the same as in ASP
StateServer = 1 server does the work
SQLServer = the database server does the work

Cookieless
Send a cookie to the client or incorporate the session ID into every request. Setting this to true has serious consequences for your search engine placement, as they don't like session IDs in your URLs.

Timeout
The time in minutes after which a session expires when being idle.

StateConnectionString
How to connect to your StatServer, this will be ignored if the mode is not set to StateServer

SqlConnectionString
How to connect to your database server, this will be ignored if the mode is not set toSQLServer

Hawkfield.Tech: Article based resource site
Hawkfield: Web design and development

< Prev   Next >

 
Antivirus Shop
BitDefender Antivirus v10
Newsflash

PowerRefresh 1.0 released!
A simple yet extremely useful tool for webmasters, publishers and SEO working bees: PowerRefresh allows you to automatically refresh your IE windows every x minutes. It can handle unlimited number of windows and, unlike similar applications, is using full browsers.


Get PowerRefresh from Kaloyani.com: download
Login Form
Username

Password

Remember me
Forgotten your password?
No account yet? Create one
Popular

VBprofs.com - online resources for Visual Basic and VB.NET professionals: Visual Basic and VB.NET articles, industry news and events, career tools, VB / VB.NET books, calendar and much more. VBprofs.com is an interactive web site with free membership.
(c) Copyright 2005 - 2006 by VBprofs.com
powered by Mambo Open Source Software
spacer