SlideShare a Scribd company logo
1 of 15
adRotator.aspx 
(3 of 4) 
51 </asp:RequiredFieldValidator> 
52 </td> 
53 </tr> 
54 </table> 
55 
56 <br /> 
57 Do you like ice cream? 
58 
59 <asp:RadioButtonList id = "iceCream" runat = "server"> 
60 <asp:ListItem>Yes</asp:ListItem> 
61 <asp:ListItem>No</asp:ListItem> 
62 </asp:RadioButtonList> 
63 
64 <br /> 
65 How many scoops would you like? (0-45) 
66 
67 <asp:TextBox id = "scoops" runat = "server" /> 
68 
69 <br /> 
70 <asp:button text = "Submit" OnClick = "submitButton_Click" 
71 runat = "server"/> 
72 
73 <asp:RangeValidator 
74 ControlToValidate = "scoops" 
75 MinimumValue = "0"
adRotator.aspx 
(4 of 4) 
76 MaximumValue = "45" 
77 Type = "Integer" 
78 EnableClientScript = "false" 
79 Text = "We cannot give you that many scoops." 
80 runat = "server" /> 
81 
82 <center> 
83 <h1> <asp:label id = "message" runat = "server"/> </h1> 
84 </center> 
85 
86 </form> 
87 </body> 
88 </html>
ads.xml 
(1 of 2) 
1 <?xml version = "1.0" ?> 
2 
3 <!-- Fig. 23.14: ads.xml --> 
4 <!-- Flag database --> 
5 
6 <Advertisements> 
7 
8 <Ad> 
9 <ImageUrl>images/unitedstates.png</ImageUrl> 
10 <NavigateUrl>http://www.usa.worldweb.com/</NavigateUrl> 
11 <AlternateText>US Tourism</AlternateText> 
12 <Impressions>80</Impressions> 
13 </Ad> 
14 
15 <Ad> 
16 <ImageUrl>images/germany.png</ImageUrl> 
17 <NavigateUrl>http://www.germany-tourism.de/</NavigateUrl> 
18 <AlternateText>German Tourism</AlternateText> 
19 <Impressions>80</Impressions> 
20 </Ad> 
21 
22 <Ad> 
23 <ImageUrl>images/spain.png</ImageUrl> 
24 <NavigateUrl>http://www.tourspain.es/</NavigateUrl> 
25 <AlternateText>Spanish Tourism</AlternateText>
ads.xml 
(2 of 2) 
26 <Impressions>80</Impressions> 
27 </Ad> 
28 
29 </Advertisements>
23.6 Web Forms 
Fig. 23.15 ASPX page with an AdRotator.
23.7 Session Tracking 
• Personalization 
• Protection of privacy 
• Cookies 
• .NET’s HttpSessionState object 
• Use of input form elements of type “hidden” 
• URL rewriting
23.7.1 Cookies 
• Customize interactions with Web pages 
• Stored by a Web site on an individual’s 
computer 
• Reactivated each time the user revisits site
cookie.aspx 
(1 of 2) 
1 <%@ Page Language="JScript" Debug="true" %> 
2 
3 <!-- Fig. 23.16: cookie.aspx --> 
4 <!-- Records last visit --> 
5 
6 <html> 
7 <head> 
8 <title> Simple Cookies </title> 
9 
10 <script runat = "server"> 
11 
12 function Page_Load( object : Object, events : EventArgs ) 
13 { 
14 var lastVisit : String; 
15 
16 if ( Request.Cookies( "visit" ) == null ) 
17 { 
18 welcome.Text = "This is the first time that " + 
19 "you have visited this site today"; 
20 } 
21 else 
22 { 
23 lastVisit = Request.Cookies( "visit" ).Value; 
24 welcome.Text = "You last visited the site at " + 
25 lastVisit + ".";
cookie.aspx 
(2 of 2) 
26 } 
27 
28 var time : DateTime = DateTime.Now; 
29 Response.Cookies( "visit" ).Value = time.ToString(); 
30 Response.Cookies( "visit" ).Expires = time.AddDays( 1 ); 
31 
32 } // end Page_Load 
33 </script> 
34 </head> 
35 <body> 
36 <form runat = "server"> 
37 <asp:label id = "welcome" runat = "server"/> 
38 </form> 
39 </body> 
40 </html>
23.7.1 Cookies 
Property Description 
Domain Returns a String containing the cookie’s domain (i.e., the domain of 
the Web server from which the cookie was downloaded). This determines 
which Web servers can receive the cookie. By default, cookies are sent to 
the Web server that originally sent them to the client. 
Expires Returns a DateTime object indicating when the browser can delete the 
cookie. 
Name Returns a String containing the cookie’s name. 
Path Returns a String containing the URL prefix for the cookie. Cookies 
can be “targeted” to specific URLs that include directories on the Web 
server, enabling the programmer to specify the location of the cookie. By 
default, a cookie is returned to services operating in the same directory as 
the service that sent the cookie or a subdirectory of that directory. 
Secure Returns a Boolean value indicating whether the cookie should be 
transmitted through a secure protocol. The value True causes a secure 
protocol to be used. 
Value Returns a String containing the cookie’s value. 
Fig. 23.17 HttpCookie properties.
23.7.2 Session Tracking with 
HttpSessionState 
Property Description 
Count Specifies the number of key-value pairs in the 
Session object. 
IsNewSession Indicates whether this is a new session (i.e., whether 
the session was created during loading of this page). 
IsReadOnly Indicates whether the Session object is read only. 
Keys Returns an object containing the Session object’s 
keys. 
SessionID Returns the session’s unique ID. 
Timeout Specifies the maximum number of minutes during 
which a session can be inactive (i.e., no requests are 
made) before the session expires. By default, this 
property is set to 20 minutes. 
Fig. 23.18 HttpSessionState properties.
optionsPage.aspx 
(1 of 6) 
1 <%@ Page Language="JScript" %> 
2 <%@ Import Namespace="System" %> 
3 
4 <%-- Fig. 23.19: optionsPage.aspx --%> 
5 <%-- Page that presents a list of language options. --%> 
6 
7 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" 
8 "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> 
9 
10 <html> 
11 <head> 
12 <title>Options Page</title> 
13 
14 <script runat = "server"> 
15 
16 // event handler for Load event 
17 var books : Hashtable = new Hashtable(); 
18 
19 function Page_Load( sender : Object, events : EventArgs ) : void 
20 { 
21 // if page is loaded due to postback, load session 
22 // information, hide language options from user 
23 books.Add( "C#", "0-13-062221-4" ); 
24 books.Add( "C++", "0-13-089571-7" ); 
25 books.Add( "C", "0-13-089572-5" );
optionsPage.aspx 
(2 of 6) 
26 books.Add( "Python", "0-13-092361-3" ); 
27 
28 if ( IsPostBack ) 
29 { 
30 // display components that contain 
31 // session information 
32 welcomeLabel.Visible = true; 
33 languageLink.Visible = true; 
34 recommendationsLink.Visible = true; 
35 
36 // hide components 
37 submitButton.Visible = false; 
38 promptLabel.Visible = false; 
39 languageList.Visible = false; 
40 
41 // set labels to display Session information 
42 if ( languageList.SelectedItem != null ) 
43 { 
44 welcomeLabel.Text += 
45 languageList.SelectedItem.ToString() + "."; 
46 } 
47 else 
48 { 
49 welcomeLabel.Text += "no language."; 
50 }
optionsPage.aspx 
(3 of 6) 
51 
52 idLabel.Text += "Your unique session ID is: " + 
53 Session.SessionID; 
54 
55 timeoutLabel.Text += "Timeout: " + 
56 Session.Timeout + " minutes"; 
57 } // end if 
58 } // end Page_Load 
59 
60 // when user clicks Submit button, 
61 // store user's choice in session object 
62 function submitButton_Click ( 
63 sender : Object, events : EventArgs ) : void 
64 { 
65 if ( languageList.SelectedItem != null ) 
66 { 
67 var language : String = 
68 languageList.SelectedItem.ToString(); 
69 
70 // note: must use ToString method because the hash table 
71 // stores information as objects 
72 var ISBN : String = books[ language ].ToString(); 
73 
74 // store in session as name-value pair 
75 // name is language chosen, value is
optionsPage.aspx 
(4 of 6) 
76 // ISBN number for corresponding book 
77 Session.Add( language, ISBN ); 
78 } // end if 
79 } // end submitButton_Click 
80 
81 </script> 
82 </head> 
83 <body> 
84 <form id = "recommendationsPage" method = "post" runat = "server"> 
85 <P> 
86 <asp:Label id = "promptLabel" runat = "server" 
87 Font-Bold = "True">Select a programming language: 
88 </asp:Label> 
89 <asp:Label id = "welcomeLabel" runat = "server" 
90 Font-Bold = "True" Visible = "False"> 
91 Welcome to Sessions! You selected 
92 </asp:Label> 
93 </P> 
94 <P> 
95 <asp:RadioButtonList id = "languageList" runat = "server"> 
96 <asp:ListItem Value = "C#">C#</asp:ListItem> 
97 <asp:ListItem Value = "C++">C++</asp:ListItem> 
98 <asp:ListItem Value = "C">C</asp:ListItem> 
99 <asp:ListItem Value = "Python">Python</asp:ListItem> 
100 </asp:RadioButtonList></P>

More Related Content

What's hot

Streaming using Kafka Flink & Elasticsearch
Streaming using Kafka Flink & ElasticsearchStreaming using Kafka Flink & Elasticsearch
Streaming using Kafka Flink & ElasticsearchKeira Zhou
 
Building Your First Data Science Applicatino in MongoDB
Building Your First Data Science Applicatino in MongoDBBuilding Your First Data Science Applicatino in MongoDB
Building Your First Data Science Applicatino in MongoDBMongoDB
 
Cnam azure 2014 mobile services
Cnam azure 2014   mobile servicesCnam azure 2014   mobile services
Cnam azure 2014 mobile servicesAymeric Weinbach
 
Delex 2020: Deep diving into the dynamic provisioning of GlusterFS volumes in...
Delex 2020: Deep diving into the dynamic provisioning of GlusterFS volumes in...Delex 2020: Deep diving into the dynamic provisioning of GlusterFS volumes in...
Delex 2020: Deep diving into the dynamic provisioning of GlusterFS volumes in...Artem Romanchik
 
Do something in 5 with gas 9-copy between databases with oauth2
Do something in 5 with gas 9-copy between databases with oauth2Do something in 5 with gas 9-copy between databases with oauth2
Do something in 5 with gas 9-copy between databases with oauth2Bruce McPherson
 
Node.js 與 google cloud storage
Node.js 與 google cloud storageNode.js 與 google cloud storage
Node.js 與 google cloud storageonlinemad
 
Using Change Streams to Keep Up with Your Data
Using Change Streams to Keep Up with Your DataUsing Change Streams to Keep Up with Your Data
Using Change Streams to Keep Up with Your DataEvan Rodd
 
Michael Hackstein - NoSQL meets Microservices - NoSQL matters Dublin 2015
Michael Hackstein - NoSQL meets Microservices - NoSQL matters Dublin 2015Michael Hackstein - NoSQL meets Microservices - NoSQL matters Dublin 2015
Michael Hackstein - NoSQL meets Microservices - NoSQL matters Dublin 2015NoSQLmatters
 
Elasticsearch und die Java-Welt
Elasticsearch und die Java-WeltElasticsearch und die Java-Welt
Elasticsearch und die Java-WeltFlorian Hopf
 
Taking Web Apps Offline
Taking Web Apps OfflineTaking Web Apps Offline
Taking Web Apps OfflinePedro Morais
 
Redis data modeling examples
Redis data modeling examplesRedis data modeling examples
Redis data modeling examplesTerry Cho
 
Back to Basics: My First MongoDB Application
Back to Basics: My First MongoDB ApplicationBack to Basics: My First MongoDB Application
Back to Basics: My First MongoDB ApplicationMongoDB
 
[MongoDB.local Bengaluru 2018] Using Change Streams to Keep Up With Your Data
[MongoDB.local Bengaluru 2018] Using Change Streams to Keep Up With Your Data[MongoDB.local Bengaluru 2018] Using Change Streams to Keep Up With Your Data
[MongoDB.local Bengaluru 2018] Using Change Streams to Keep Up With Your DataMongoDB
 
Map/Confused? A practical approach to Map/Reduce with MongoDB
Map/Confused? A practical approach to Map/Reduce with MongoDBMap/Confused? A practical approach to Map/Reduce with MongoDB
Map/Confused? A practical approach to Map/Reduce with MongoDBUwe Printz
 
Use Kotlin scripts and Clova SDK to build your Clova extension
Use Kotlin scripts and Clova SDK to build your Clova extensionUse Kotlin scripts and Clova SDK to build your Clova extension
Use Kotlin scripts and Clova SDK to build your Clova extensionLINE Corporation
 
KEYNOTE: Node.js interactive 2017 - The case for node.js
KEYNOTE: Node.js interactive 2017 - The case for node.jsKEYNOTE: Node.js interactive 2017 - The case for node.js
KEYNOTE: Node.js interactive 2017 - The case for node.jsJustin Beckwith
 

What's hot (20)

Streaming using Kafka Flink & Elasticsearch
Streaming using Kafka Flink & ElasticsearchStreaming using Kafka Flink & Elasticsearch
Streaming using Kafka Flink & Elasticsearch
 
Building Your First Data Science Applicatino in MongoDB
Building Your First Data Science Applicatino in MongoDBBuilding Your First Data Science Applicatino in MongoDB
Building Your First Data Science Applicatino in MongoDB
 
Cnam azure 2014 mobile services
Cnam azure 2014   mobile servicesCnam azure 2014   mobile services
Cnam azure 2014 mobile services
 
Ecom2
Ecom2Ecom2
Ecom2
 
Client Web
Client WebClient Web
Client Web
 
MongoDB
MongoDBMongoDB
MongoDB
 
Delex 2020: Deep diving into the dynamic provisioning of GlusterFS volumes in...
Delex 2020: Deep diving into the dynamic provisioning of GlusterFS volumes in...Delex 2020: Deep diving into the dynamic provisioning of GlusterFS volumes in...
Delex 2020: Deep diving into the dynamic provisioning of GlusterFS volumes in...
 
Do something in 5 with gas 9-copy between databases with oauth2
Do something in 5 with gas 9-copy between databases with oauth2Do something in 5 with gas 9-copy between databases with oauth2
Do something in 5 with gas 9-copy between databases with oauth2
 
Node.js 與 google cloud storage
Node.js 與 google cloud storageNode.js 與 google cloud storage
Node.js 與 google cloud storage
 
Mongo db presentation
Mongo db presentationMongo db presentation
Mongo db presentation
 
Using Change Streams to Keep Up with Your Data
Using Change Streams to Keep Up with Your DataUsing Change Streams to Keep Up with Your Data
Using Change Streams to Keep Up with Your Data
 
Michael Hackstein - NoSQL meets Microservices - NoSQL matters Dublin 2015
Michael Hackstein - NoSQL meets Microservices - NoSQL matters Dublin 2015Michael Hackstein - NoSQL meets Microservices - NoSQL matters Dublin 2015
Michael Hackstein - NoSQL meets Microservices - NoSQL matters Dublin 2015
 
Elasticsearch und die Java-Welt
Elasticsearch und die Java-WeltElasticsearch und die Java-Welt
Elasticsearch und die Java-Welt
 
Taking Web Apps Offline
Taking Web Apps OfflineTaking Web Apps Offline
Taking Web Apps Offline
 
Redis data modeling examples
Redis data modeling examplesRedis data modeling examples
Redis data modeling examples
 
Back to Basics: My First MongoDB Application
Back to Basics: My First MongoDB ApplicationBack to Basics: My First MongoDB Application
Back to Basics: My First MongoDB Application
 
[MongoDB.local Bengaluru 2018] Using Change Streams to Keep Up With Your Data
[MongoDB.local Bengaluru 2018] Using Change Streams to Keep Up With Your Data[MongoDB.local Bengaluru 2018] Using Change Streams to Keep Up With Your Data
[MongoDB.local Bengaluru 2018] Using Change Streams to Keep Up With Your Data
 
Map/Confused? A practical approach to Map/Reduce with MongoDB
Map/Confused? A practical approach to Map/Reduce with MongoDBMap/Confused? A practical approach to Map/Reduce with MongoDB
Map/Confused? A practical approach to Map/Reduce with MongoDB
 
Use Kotlin scripts and Clova SDK to build your Clova extension
Use Kotlin scripts and Clova SDK to build your Clova extensionUse Kotlin scripts and Clova SDK to build your Clova extension
Use Kotlin scripts and Clova SDK to build your Clova extension
 
KEYNOTE: Node.js interactive 2017 - The case for node.js
KEYNOTE: Node.js interactive 2017 - The case for node.jsKEYNOTE: Node.js interactive 2017 - The case for node.js
KEYNOTE: Node.js interactive 2017 - The case for node.js
 

Similar to ASP.NET Session Tracking and Cookies

Synapse india reviews sharing chapter 23 – asp.net-part2
Synapse india reviews sharing  chapter 23 – asp.net-part2Synapse india reviews sharing  chapter 23 – asp.net-part2
Synapse india reviews sharing chapter 23 – asp.net-part2Synapseindiappsdevelopment
 
Asp.net state management
Asp.net state managementAsp.net state management
Asp.net state managementpriya Nithya
 
JavaScript - Chapter 13 - Browser Object Model(BOM)
JavaScript - Chapter 13 - Browser Object Model(BOM)JavaScript - Chapter 13 - Browser Object Model(BOM)
JavaScript - Chapter 13 - Browser Object Model(BOM)WebStackAcademy
 
The complete ASP.NET (IIS) Tutorial with code example in power point slide show
The complete ASP.NET (IIS) Tutorial with code example in power point slide showThe complete ASP.NET (IIS) Tutorial with code example in power point slide show
The complete ASP.NET (IIS) Tutorial with code example in power point slide showSubhas Malik
 
Developing your first application using FIWARE
Developing your first application using FIWAREDeveloping your first application using FIWARE
Developing your first application using FIWAREFIWARE
 
ASP.NET Overview - Alvin Lau
ASP.NET Overview - Alvin LauASP.NET Overview - Alvin Lau
ASP.NET Overview - Alvin LauSpiffy
 
OSGi and Spring Data for simple (Web) Application Development
OSGi and Spring Data  for simple (Web) Application DevelopmentOSGi and Spring Data  for simple (Web) Application Development
OSGi and Spring Data for simple (Web) Application DevelopmentChristian Baranowski
 
OSGi and Spring Data for simple (Web) Application Development - Christian Bar...
OSGi and Spring Data for simple (Web) Application Development - Christian Bar...OSGi and Spring Data for simple (Web) Application Development - Christian Bar...
OSGi and Spring Data for simple (Web) Application Development - Christian Bar...mfrancis
 
Dynamic HTML Event Model
Dynamic HTML Event ModelDynamic HTML Event Model
Dynamic HTML Event ModelReem Alattas
 
Java script Advance
Java script   AdvanceJava script   Advance
Java script AdvanceJaya Kumari
 
Windows 8 metro applications
Windows 8 metro applicationsWindows 8 metro applications
Windows 8 metro applicationsAlex Golesh
 
Drive chrome(headless) with puppeteer
Drive chrome(headless) with puppeteerDrive chrome(headless) with puppeteer
Drive chrome(headless) with puppeteerVodqaBLR
 
AtlasCamp 2014: 10 Things a Front End Developer Should Know About Connect
AtlasCamp 2014: 10 Things a Front End Developer Should Know About ConnectAtlasCamp 2014: 10 Things a Front End Developer Should Know About Connect
AtlasCamp 2014: 10 Things a Front End Developer Should Know About ConnectAtlassian
 
Web Technologies - forms and actions
Web Technologies -  forms and actionsWeb Technologies -  forms and actions
Web Technologies - forms and actionsAren Zomorodian
 

Similar to ASP.NET Session Tracking and Cookies (20)

Synapse india dotnet development web approch
Synapse india dotnet development web approchSynapse india dotnet development web approch
Synapse india dotnet development web approch
 
Synapse india reviews sharing chapter 23 – asp.net-part2
Synapse india reviews sharing  chapter 23 – asp.net-part2Synapse india reviews sharing  chapter 23 – asp.net-part2
Synapse india reviews sharing chapter 23 – asp.net-part2
 
Asp.net state management
Asp.net state managementAsp.net state management
Asp.net state management
 
JavaScript - Chapter 13 - Browser Object Model(BOM)
JavaScript - Chapter 13 - Browser Object Model(BOM)JavaScript - Chapter 13 - Browser Object Model(BOM)
JavaScript - Chapter 13 - Browser Object Model(BOM)
 
The complete ASP.NET (IIS) Tutorial with code example in power point slide show
The complete ASP.NET (IIS) Tutorial with code example in power point slide showThe complete ASP.NET (IIS) Tutorial with code example in power point slide show
The complete ASP.NET (IIS) Tutorial with code example in power point slide show
 
Developing your first application using FIWARE
Developing your first application using FIWAREDeveloping your first application using FIWARE
Developing your first application using FIWARE
 
ASP.NET Overview - Alvin Lau
ASP.NET Overview - Alvin LauASP.NET Overview - Alvin Lau
ASP.NET Overview - Alvin Lau
 
OSGi and Spring Data for simple (Web) Application Development
OSGi and Spring Data  for simple (Web) Application DevelopmentOSGi and Spring Data  for simple (Web) Application Development
OSGi and Spring Data for simple (Web) Application Development
 
OSGi and Spring Data for simple (Web) Application Development - Christian Bar...
OSGi and Spring Data for simple (Web) Application Development - Christian Bar...OSGi and Spring Data for simple (Web) Application Development - Christian Bar...
OSGi and Spring Data for simple (Web) Application Development - Christian Bar...
 
Pushing the Web: Interesting things to Know
Pushing the Web: Interesting things to KnowPushing the Web: Interesting things to Know
Pushing the Web: Interesting things to Know
 
Dynamic HTML Event Model
Dynamic HTML Event ModelDynamic HTML Event Model
Dynamic HTML Event Model
 
Html5 For Jjugccc2009fall
Html5 For Jjugccc2009fallHtml5 For Jjugccc2009fall
Html5 For Jjugccc2009fall
 
Java script Advance
Java script   AdvanceJava script   Advance
Java script Advance
 
Windows 8 metro applications
Windows 8 metro applicationsWindows 8 metro applications
Windows 8 metro applications
 
Drive chrome(headless) with puppeteer
Drive chrome(headless) with puppeteerDrive chrome(headless) with puppeteer
Drive chrome(headless) with puppeteer
 
Tutorial asp.net
Tutorial  asp.netTutorial  asp.net
Tutorial asp.net
 
The Devil and HTML5
The Devil and HTML5The Devil and HTML5
The Devil and HTML5
 
AtlasCamp 2014: 10 Things a Front End Developer Should Know About Connect
AtlasCamp 2014: 10 Things a Front End Developer Should Know About ConnectAtlasCamp 2014: 10 Things a Front End Developer Should Know About Connect
AtlasCamp 2014: 10 Things a Front End Developer Should Know About Connect
 
Chapter 11
Chapter 11Chapter 11
Chapter 11
 
Web Technologies - forms and actions
Web Technologies -  forms and actionsWeb Technologies -  forms and actions
Web Technologies - forms and actions
 

More from Synapseindiappsdevelopment

Synapse india elance top in demand in it skills
Synapse india elance top in demand in it skillsSynapse india elance top in demand in it skills
Synapse india elance top in demand in it skillsSynapseindiappsdevelopment
 
SynapseIndia dotnet web development architecture module
SynapseIndia dotnet web development architecture moduleSynapseIndia dotnet web development architecture module
SynapseIndia dotnet web development architecture moduleSynapseindiappsdevelopment
 
SynapseIndia dotnet development platform overview
SynapseIndia  dotnet development platform overviewSynapseIndia  dotnet development platform overview
SynapseIndia dotnet development platform overviewSynapseindiappsdevelopment
 
SynapseIndia dotnet web applications development
SynapseIndia  dotnet web applications developmentSynapseIndia  dotnet web applications development
SynapseIndia dotnet web applications developmentSynapseindiappsdevelopment
 
SynapseIndia dotnet website security development
SynapseIndia  dotnet website security developmentSynapseIndia  dotnet website security development
SynapseIndia dotnet website security developmentSynapseindiappsdevelopment
 
SynapseIndia mobile apps deployment framework internal architecture
SynapseIndia mobile apps deployment framework internal architectureSynapseIndia mobile apps deployment framework internal architecture
SynapseIndia mobile apps deployment framework internal architectureSynapseindiappsdevelopment
 
SynapseIndia dotnet development ajax client library
SynapseIndia dotnet development ajax client librarySynapseIndia dotnet development ajax client library
SynapseIndia dotnet development ajax client librarySynapseindiappsdevelopment
 
SynapseIndia mobile apps deployment framework architecture
SynapseIndia mobile apps deployment framework architectureSynapseIndia mobile apps deployment framework architecture
SynapseIndia mobile apps deployment framework architectureSynapseindiappsdevelopment
 
SynapseIndia dotnet client library Development
SynapseIndia dotnet client library DevelopmentSynapseIndia dotnet client library Development
SynapseIndia dotnet client library DevelopmentSynapseindiappsdevelopment
 
SynapseIndia creating asp controls programatically development
SynapseIndia creating asp controls programatically developmentSynapseIndia creating asp controls programatically development
SynapseIndia creating asp controls programatically developmentSynapseindiappsdevelopment
 

More from Synapseindiappsdevelopment (20)

Synapse india elance top in demand in it skills
Synapse india elance top in demand in it skillsSynapse india elance top in demand in it skills
Synapse india elance top in demand in it skills
 
SynapseIndia dotnet web development architecture module
SynapseIndia dotnet web development architecture moduleSynapseIndia dotnet web development architecture module
SynapseIndia dotnet web development architecture module
 
SynapseIndia dotnet module development part 1
SynapseIndia  dotnet module development part 1SynapseIndia  dotnet module development part 1
SynapseIndia dotnet module development part 1
 
SynapseIndia dotnet framework library
SynapseIndia  dotnet framework librarySynapseIndia  dotnet framework library
SynapseIndia dotnet framework library
 
SynapseIndia dotnet development platform overview
SynapseIndia  dotnet development platform overviewSynapseIndia  dotnet development platform overview
SynapseIndia dotnet development platform overview
 
SynapseIndia dotnet development framework
SynapseIndia  dotnet development frameworkSynapseIndia  dotnet development framework
SynapseIndia dotnet development framework
 
SynapseIndia dotnet web applications development
SynapseIndia  dotnet web applications developmentSynapseIndia  dotnet web applications development
SynapseIndia dotnet web applications development
 
SynapseIndia dotnet website security development
SynapseIndia  dotnet website security developmentSynapseIndia  dotnet website security development
SynapseIndia dotnet website security development
 
SynapseIndia mobile build apps management
SynapseIndia mobile build apps managementSynapseIndia mobile build apps management
SynapseIndia mobile build apps management
 
SynapseIndia mobile apps deployment framework internal architecture
SynapseIndia mobile apps deployment framework internal architectureSynapseIndia mobile apps deployment framework internal architecture
SynapseIndia mobile apps deployment framework internal architecture
 
SynapseIndia java and .net development
SynapseIndia java and .net developmentSynapseIndia java and .net development
SynapseIndia java and .net development
 
SynapseIndia dotnet development panel control
SynapseIndia dotnet development panel controlSynapseIndia dotnet development panel control
SynapseIndia dotnet development panel control
 
SynapseIndia dotnet development ajax client library
SynapseIndia dotnet development ajax client librarySynapseIndia dotnet development ajax client library
SynapseIndia dotnet development ajax client library
 
SynapseIndia php web development
SynapseIndia php web developmentSynapseIndia php web development
SynapseIndia php web development
 
SynapseIndia mobile apps architecture
SynapseIndia mobile apps architectureSynapseIndia mobile apps architecture
SynapseIndia mobile apps architecture
 
SynapseIndia mobile apps deployment framework architecture
SynapseIndia mobile apps deployment framework architectureSynapseIndia mobile apps deployment framework architecture
SynapseIndia mobile apps deployment framework architecture
 
SynapseIndia mobile apps
SynapseIndia mobile appsSynapseIndia mobile apps
SynapseIndia mobile apps
 
SynapseIndia dotnet development
SynapseIndia dotnet developmentSynapseIndia dotnet development
SynapseIndia dotnet development
 
SynapseIndia dotnet client library Development
SynapseIndia dotnet client library DevelopmentSynapseIndia dotnet client library Development
SynapseIndia dotnet client library Development
 
SynapseIndia creating asp controls programatically development
SynapseIndia creating asp controls programatically developmentSynapseIndia creating asp controls programatically development
SynapseIndia creating asp controls programatically development
 

Recently uploaded

My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Neo4j
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxnull - The Open Security Community
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDGMarianaLemus7
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
Unlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power SystemsUnlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power SystemsPrecisely
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024BookNet Canada
 
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsSnow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsHyundai Motor Group
 

Recently uploaded (20)

My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
The transition to renewables in India.pdf
The transition to renewables in India.pdfThe transition to renewables in India.pdf
The transition to renewables in India.pdf
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024
 
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort ServiceHot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDG
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
Unlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power SystemsUnlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power Systems
 
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptxVulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
 
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsSnow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
 

ASP.NET Session Tracking and Cookies

  • 1. adRotator.aspx (3 of 4) 51 </asp:RequiredFieldValidator> 52 </td> 53 </tr> 54 </table> 55 56 <br /> 57 Do you like ice cream? 58 59 <asp:RadioButtonList id = "iceCream" runat = "server"> 60 <asp:ListItem>Yes</asp:ListItem> 61 <asp:ListItem>No</asp:ListItem> 62 </asp:RadioButtonList> 63 64 <br /> 65 How many scoops would you like? (0-45) 66 67 <asp:TextBox id = "scoops" runat = "server" /> 68 69 <br /> 70 <asp:button text = "Submit" OnClick = "submitButton_Click" 71 runat = "server"/> 72 73 <asp:RangeValidator 74 ControlToValidate = "scoops" 75 MinimumValue = "0"
  • 2. adRotator.aspx (4 of 4) 76 MaximumValue = "45" 77 Type = "Integer" 78 EnableClientScript = "false" 79 Text = "We cannot give you that many scoops." 80 runat = "server" /> 81 82 <center> 83 <h1> <asp:label id = "message" runat = "server"/> </h1> 84 </center> 85 86 </form> 87 </body> 88 </html>
  • 3. ads.xml (1 of 2) 1 <?xml version = "1.0" ?> 2 3 <!-- Fig. 23.14: ads.xml --> 4 <!-- Flag database --> 5 6 <Advertisements> 7 8 <Ad> 9 <ImageUrl>images/unitedstates.png</ImageUrl> 10 <NavigateUrl>http://www.usa.worldweb.com/</NavigateUrl> 11 <AlternateText>US Tourism</AlternateText> 12 <Impressions>80</Impressions> 13 </Ad> 14 15 <Ad> 16 <ImageUrl>images/germany.png</ImageUrl> 17 <NavigateUrl>http://www.germany-tourism.de/</NavigateUrl> 18 <AlternateText>German Tourism</AlternateText> 19 <Impressions>80</Impressions> 20 </Ad> 21 22 <Ad> 23 <ImageUrl>images/spain.png</ImageUrl> 24 <NavigateUrl>http://www.tourspain.es/</NavigateUrl> 25 <AlternateText>Spanish Tourism</AlternateText>
  • 4. ads.xml (2 of 2) 26 <Impressions>80</Impressions> 27 </Ad> 28 29 </Advertisements>
  • 5. 23.6 Web Forms Fig. 23.15 ASPX page with an AdRotator.
  • 6. 23.7 Session Tracking • Personalization • Protection of privacy • Cookies • .NET’s HttpSessionState object • Use of input form elements of type “hidden” • URL rewriting
  • 7. 23.7.1 Cookies • Customize interactions with Web pages • Stored by a Web site on an individual’s computer • Reactivated each time the user revisits site
  • 8. cookie.aspx (1 of 2) 1 <%@ Page Language="JScript" Debug="true" %> 2 3 <!-- Fig. 23.16: cookie.aspx --> 4 <!-- Records last visit --> 5 6 <html> 7 <head> 8 <title> Simple Cookies </title> 9 10 <script runat = "server"> 11 12 function Page_Load( object : Object, events : EventArgs ) 13 { 14 var lastVisit : String; 15 16 if ( Request.Cookies( "visit" ) == null ) 17 { 18 welcome.Text = "This is the first time that " + 19 "you have visited this site today"; 20 } 21 else 22 { 23 lastVisit = Request.Cookies( "visit" ).Value; 24 welcome.Text = "You last visited the site at " + 25 lastVisit + ".";
  • 9. cookie.aspx (2 of 2) 26 } 27 28 var time : DateTime = DateTime.Now; 29 Response.Cookies( "visit" ).Value = time.ToString(); 30 Response.Cookies( "visit" ).Expires = time.AddDays( 1 ); 31 32 } // end Page_Load 33 </script> 34 </head> 35 <body> 36 <form runat = "server"> 37 <asp:label id = "welcome" runat = "server"/> 38 </form> 39 </body> 40 </html>
  • 10. 23.7.1 Cookies Property Description Domain Returns a String containing the cookie’s domain (i.e., the domain of the Web server from which the cookie was downloaded). This determines which Web servers can receive the cookie. By default, cookies are sent to the Web server that originally sent them to the client. Expires Returns a DateTime object indicating when the browser can delete the cookie. Name Returns a String containing the cookie’s name. Path Returns a String containing the URL prefix for the cookie. Cookies can be “targeted” to specific URLs that include directories on the Web server, enabling the programmer to specify the location of the cookie. By default, a cookie is returned to services operating in the same directory as the service that sent the cookie or a subdirectory of that directory. Secure Returns a Boolean value indicating whether the cookie should be transmitted through a secure protocol. The value True causes a secure protocol to be used. Value Returns a String containing the cookie’s value. Fig. 23.17 HttpCookie properties.
  • 11. 23.7.2 Session Tracking with HttpSessionState Property Description Count Specifies the number of key-value pairs in the Session object. IsNewSession Indicates whether this is a new session (i.e., whether the session was created during loading of this page). IsReadOnly Indicates whether the Session object is read only. Keys Returns an object containing the Session object’s keys. SessionID Returns the session’s unique ID. Timeout Specifies the maximum number of minutes during which a session can be inactive (i.e., no requests are made) before the session expires. By default, this property is set to 20 minutes. Fig. 23.18 HttpSessionState properties.
  • 12. optionsPage.aspx (1 of 6) 1 <%@ Page Language="JScript" %> 2 <%@ Import Namespace="System" %> 3 4 <%-- Fig. 23.19: optionsPage.aspx --%> 5 <%-- Page that presents a list of language options. --%> 6 7 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" 8 "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> 9 10 <html> 11 <head> 12 <title>Options Page</title> 13 14 <script runat = "server"> 15 16 // event handler for Load event 17 var books : Hashtable = new Hashtable(); 18 19 function Page_Load( sender : Object, events : EventArgs ) : void 20 { 21 // if page is loaded due to postback, load session 22 // information, hide language options from user 23 books.Add( "C#", "0-13-062221-4" ); 24 books.Add( "C++", "0-13-089571-7" ); 25 books.Add( "C", "0-13-089572-5" );
  • 13. optionsPage.aspx (2 of 6) 26 books.Add( "Python", "0-13-092361-3" ); 27 28 if ( IsPostBack ) 29 { 30 // display components that contain 31 // session information 32 welcomeLabel.Visible = true; 33 languageLink.Visible = true; 34 recommendationsLink.Visible = true; 35 36 // hide components 37 submitButton.Visible = false; 38 promptLabel.Visible = false; 39 languageList.Visible = false; 40 41 // set labels to display Session information 42 if ( languageList.SelectedItem != null ) 43 { 44 welcomeLabel.Text += 45 languageList.SelectedItem.ToString() + "."; 46 } 47 else 48 { 49 welcomeLabel.Text += "no language."; 50 }
  • 14. optionsPage.aspx (3 of 6) 51 52 idLabel.Text += "Your unique session ID is: " + 53 Session.SessionID; 54 55 timeoutLabel.Text += "Timeout: " + 56 Session.Timeout + " minutes"; 57 } // end if 58 } // end Page_Load 59 60 // when user clicks Submit button, 61 // store user's choice in session object 62 function submitButton_Click ( 63 sender : Object, events : EventArgs ) : void 64 { 65 if ( languageList.SelectedItem != null ) 66 { 67 var language : String = 68 languageList.SelectedItem.ToString(); 69 70 // note: must use ToString method because the hash table 71 // stores information as objects 72 var ISBN : String = books[ language ].ToString(); 73 74 // store in session as name-value pair 75 // name is language chosen, value is
  • 15. optionsPage.aspx (4 of 6) 76 // ISBN number for corresponding book 77 Session.Add( language, ISBN ); 78 } // end if 79 } // end submitButton_Click 80 81 </script> 82 </head> 83 <body> 84 <form id = "recommendationsPage" method = "post" runat = "server"> 85 <P> 86 <asp:Label id = "promptLabel" runat = "server" 87 Font-Bold = "True">Select a programming language: 88 </asp:Label> 89 <asp:Label id = "welcomeLabel" runat = "server" 90 Font-Bold = "True" Visible = "False"> 91 Welcome to Sessions! You selected 92 </asp:Label> 93 </P> 94 <P> 95 <asp:RadioButtonList id = "languageList" runat = "server"> 96 <asp:ListItem Value = "C#">C#</asp:ListItem> 97 <asp:ListItem Value = "C++">C++</asp:ListItem> 98 <asp:ListItem Value = "C">C</asp:ListItem> 99 <asp:ListItem Value = "Python">Python</asp:ListItem> 100 </asp:RadioButtonList></P>