Building Applications using ASP.NET and C# / Session 5 / 1 of 19 Session 5.

Slides:



Advertisements
Similar presentations
Unit 02. ASP.NET Introduction HTML & Server controls Postbacks Page Lifecycle.
Advertisements

Java Script Session1 INTRODUCTION.
CIS 451: ASP Sessions and Applications Dr. Ralph D. Westfall January, 2009.
Working with Session and Application Objects. Postback and Variables Variables declared in a web page including ADO.Net objects may be reinitialized and.
Chapter 1: An Introduction To ASP.NET Web Programming
1 Active Server Pages Active Server Pages (ASPs) are Web pages ASP = server-side scripts + HTML The appearance of an Active Server Page depends on who.
Multiple Tiers in Action
Server-Side Scripting with ASP.Net ISYS 546. ASP.NET ASP.NET is a server-side technology for creating dynamic web pages. ASP.NET allows you to use a selection.
ASP.NET 2.0 Chapter 6 Securing the ASP.NET Application.
Chapter 11 ASP.NET JavaScript, Third Edition. 2 Objectives Learn about client/server architecture Study server-side scripting Create ASP.NET applications.
Mark Dixon, SoCCE SOFT 131Page 1 19 – Web applications: Server-side code (ASP)
Christopher M. Pascucci Basic Structural Concepts of.NET Browser – Server Interaction.
IT533 Lectures Configuring, Deploying, Tracing and Error Handling.
Tutorial: Introduction to ASP.NET Internet Technologies and Web Application 4 th February 2010.
FALL 2005CSI 4118 – UNIVERSITY OF OTTAWA1 Part 4 Web technologies: HTTP, CGI, PHP,Java applets)
Global web applications1 Adapting ASP.NET web applications to work in different cultures.
INTERNET APPLICATION DEVELOPMENT For More visit:
© 2008 Dr. Paul Walcott – The University of the West Indies: Cave Hill CampusDr. Paul Walcott COMP6325 Advanced Web Technologies Dr. Paul Walcott The University.
Beginning Web Site Development Module 1 – Dynamic Web Site Development Fundamentals of building dynamic Web sites with ASP.NET 2.0 and C# Version.
CPSC203 Introduction to Computers Lab 69 By Jie Gao.
Advanced Web Forms with Databases Programming Right from the Start with Visual Basic.NET 1/e 13.
CIS 375—Web App Dev II ASP II. 2 ASP Session: Introduction The Session _______ is used to store information about, or change settings for a user session.
ASP Hello, world. ServerClient Response Request A form.
Session 10: Managing State. Overview State Management Types of State Management Server-Side State Management Client-Side State Management The Global.asax.
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3 Managing State.
State Management. What is State management Why State management ViewState QueryString Cookies.
Elements of ASP Documents Adapted from MCDN Web Workshop ( and Webmonkey’s Introduction to Active.
Python CGI programming
ASP The Global.asa file Y.-H. Chen International College Ming-Chuan University Fall, 2004.
ASP.NET.. ASP.NET Environment ASP.NET is Microsoft's programming framework that enables the development of Web applications and services. It is an easy.
Tracing 1www.tech.findforinfo.com. Contents Why Tracing Why Tracing Tracing in ASP.NET Tracing in ASP.NET Page Level tracing Page Level tracing Application.
1 Chapter 9 – Cookies, Sessions, FTP, and More spring into PHP 5 by Steven Holzner Slides were developed by Jack Davis College of Information Science.
11 1 Cookies CGI/Perl Programming By Diane Zak Objectives In this chapter, you will: Learn the difference between temporary and persistent cookies.
Working with the Application Object. Session VS Application Object The Session object helps to preserve data on a per user basis. What if we want to initialize.
Christopher M. Pascucci Basic Structural Concepts of.NET Managing State & Scope.
Global.asax file. Agenda What is Global.asax file How to add the Global.asax file What are the default events available Explanation to Application_Level.
Introduction to ASP.Net ISYS 512. ASP.NET in the.NET Framework 1. The client requests a web page. 2. The web server locates the page. 3. If the page is.
Building Applications using ASP.NET and C# / Session 15 / 1 of 17 Sessio n 15.
COOKIES and SESSIONS. COOKIES A cookie is often used to identify a user. A cookie is a small file that the server embeds on the user's computer. Each.
Web Database Programming Week 7 Session Management & Authentication.
The Problem of State. We will look at… Sometimes web development is just plain weird! Internet / World Wide Web Aspects of their operation The role of.
Lecture Note 8: ASP Including Files and The Global.asa file.
ASP. What is ASP? ASP stands for Active Server Pages ASP is a Microsoft Technology ASP is a program that runs inside IIS IIS stands for Internet Information.
The Module Road Map Assignment 1 Road Map We will look at… Internet / World Wide Web Aspects of their operation The role of clients and servers ASPX.
Module 4: Creating a Web Application with Web Forms
ASP (COMPONENTS) Active Server Pages (cont..) 1. global.asa file The Global.asa file is an optional file that can contain declarations of objects, variables,
Working With ASP.NET Application. Create a new virtual directory The procedure to create a new virtual directory Internet Services Manager Right click.
ASP.NET P AGE O BJECTS.  Each ASP.NET page inherits the PAGE object  The PAGE supplies 3 built in objects:  REQUEST: All information passed to the.
SESSIONS 27/2/12 Lecture 8. ? Operator Similar to the if statement but returns a value derived from one of two expressions by a colon. Syntax: (expression)
Maintaining State in ASP. Problem - How do I maintain state information about the user  Several Methods –Cookies –Session variables –Hidden fields 
Overview of Previous Lesson(s) Over View  ASP is a technology that enables scripts in web pages to be executed by an Internet server.  ASP.NET is a.
Application Object Controlling the Application Application Object Controlling the Application.
Active Server Pages Session - 3. Response Request ApplicationObjectContext Server Session Error ASP Objects.
7-1 Active Server and ADO Colorado Technical University IT420 Tim Peterson.
Unit-6 Handling Sessions and Cookies. Concept of Session Session values are store in server side not in user’s machine. A session is available as long.
Session 11: Cookies, Sessions ans Security iNET Academy Open Source Web Development.
Server Object Server Object. The Server object represents a programmable interface to the HTTP service that provides a mechanism to administer and control.
ASP.NET State Management Overview Prepared By Manish Kumar Aery(IM66) Department of computer Application IET Bhaddal (Ropar)
111 State Management Beginning ASP.NET in C# and VB Chapter 4 Pages
Fundamentals of Web DevelopmentRandy Connolly and Ricardo HoarFundamentals of Web DevelopmentRandy Connolly and Ricardo Hoar Fundamentals of Web DevelopmentRandy.
Computing with C# and the .NET Framework
Internet Programming Chapter 9: State Management in ASP.NET
Active Server Pages ASP.Net
Implementing Cookies in PHP
Chapter 2 Interacting with the Customer
Working with Session and Application Objects
5/6/2019 Session 8.2 Postback, ViewState
Cookies A cookie is often used to identify a user. A cookie is a small file that the server embeds on the user's computer. Each time the same computer.
Your computer is the client
A Little Bit of Active Server Pages (ASP)
Presentation transcript:

Building Applications using ASP.NET and C# / Session 5 / 1 of 19 Session 5

Building Applications using ASP.NET and C# / Session 5 / 2 of 19 Session Objectives Discuss the Global.asax file Explain events in Global.asax file Use the Application object Use the Server object

Building Applications using ASP.NET and C# / Session 5 / 3 of 19Global.asax Stored in Root Directory of application Defines boundary of application Initialise application or session level variables Connect to databases Send cookies

Building Applications using ASP.NET and C# / Session 5 / 4 of 19 Events in Global.asax - 1 EventsFired When Application_OnStartFired when the first ASP.NET page in the current application directory (or its sub-directories) is called. Application_OnEndFired when the last session of the application ends. Also fired when the web application is stopped using the Internet Services Manger snap-in. Application_OnBeginRequestFired every time a page request begins (ideally when a page is loaded or refreshed). Application_OnEndRequestFired every time a page request ends (that is every time the page executes on the browser) Session_OnStartFired every time a new session begins. Session_OnEndFired when the session ends. For the various ways in which a session can end refer to the session on the Session object.

Building Applications using ASP.NET and C# / Session 5 / 5 of 19 Events in Global. asax - 2

Building Applications using ASP.NET and C# / Session 5 / 6 of 19 Application Object - 1 Represents an instance of an ASP.NET application. Object[varName] Application ["greeting"] = "Welcome to my World";

Building Applications using ASP.NET and C# / Session 5 / 7 of 19 Application Object - 2 void Application_OnStart(Object sender, EventArgs E) { Application ["greeting"] = "Welcome to my World"; } void Page_Load(Object Src, EventArgs E){ Response.Write(Application ["greeting"]); }

Building Applications using ASP.NET and C# / Session 5 / 8 of 19 Application Object - 3 void Application_OnStart(Object sender, EventArgs E) { Application ["Counter"] = 0; } void Page_Load(Object Src, EventArgs E){ Application["Counter"] = (Int32) Application ["Counter"] + 1; Response.Write("You are visitor number :" + Application ["Counter"]); } <FONT SIZE = 5 COLOR = RED>Welcome to my World

Building Applications using ASP.NET and C# / Session 5 / 9 of 19 Application Object - 4

Building Applications using ASP.NET and C# / Session 5 / 10 of 19 Controlling Access void Page_Load(Object Src, EventArgs E) { Application.Lock(); Application["Counter"] = (Int32) Application ["Counter"] + 1; Application.UnLock(); } This page has been visited times!!

Building Applications using ASP.NET and C# / Session 5 / 11 of 19Arrays void Application_Start(Object sender, EventArgs E) { String [] job = new String [4]; job[0]= "Faculty"; job[1]= "Programmer"; job[2]= "Salesman"; job[3]= "Manager"; Application ["j"] = job; } void Page_Load(Object Src, EventArgs E) { int i = 0; String[] k; k = (String[])Application["j"]; for (i = 0; i<k.Length;i++) { Response.Write(k[i] + " "); } }

Building Applications using ASP.NET and C# / Session 5 / 12 of 19 Server Object Execute and Transfer HTMLEncode URLEncode MapPath PropertyDescription ScriptTimeoutIs used to specify the period for which a script can run on the server before it is terminated. MachineNameIs used to get the machine name of the server. Server.property | method

Building Applications using ASP.NET and C# / Session 5 / 13 of 19 Execute Method void clicked (Object Src, EventArgs E){ Server.Execute("/test/ses6ex1.aspx");}

Building Applications using ASP.NET and C# / Session 5 / 14 of 19 Transfer Method Server.Transfer("/test/transfer.aspx");

Building Applications using ASP.NET and C# / Session 5 / 15 of 19 HTMLEncode Method Response.Write( Server.HtmlEncode(" is an example of a Heading tag ")); Server.HTMLEncode (string) Response.Write(" is an example of a Heading tag ");

Building Applications using ASP.NET and C# / Session 5 / 16 of 19 URLEncode Method - 1 Response.Write(Server.UrlEncode(" t/code/map.aspx")); Server.URLEncode (string)

Building Applications using ASP.NET and C# / Session 5 / 17 of 19 URLEncode Method - 2 void clicked (Object Src, EventArgs E) { String name = Server.UrlEncode("John Saunders"); Response.Redirect (" + name); } void clicked (Object Src, EventArgs E) { String name = Server.UrlEncode("John Saunders"); Response.Redirect (" + name); }

Building Applications using ASP.NET and C# / Session 5 / 18 of 19 URLEncode Method - 3 void clicked (Object Src, EventArgs E){ String name = Server.UrlEncode("John Saunders"); String password = Server.UrlEncode("king"); Response.Redirect(" me=" + name + " &password=" + password); } void clicked (Object Src, EventArgs E){ String name = Server.UrlEncode("John Saunders"); String password = Server.UrlEncode("king"); Response.Redirect(" me=" + name + " &password=" + password); }

Building Applications using ASP.NET and C# / Session 5 / 19 of 19 MapPath Method Response.Write( Server.MapPath("/encode.aspx")); Response.Write( Server.MapPath("encode.aspx")); Response.Write(Server.MapPath(Request.ServerVari ables.Get("PATH_INFO"))); Server.MapPath (path)