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.

Slides:



Advertisements
Similar presentations
UFCE8V-20-3 Information Systems Development 3 (SHAPE HK)
Advertisements

1 Configuring Internet- related services (April 22, 2015) © Abdou Illia, Spring 2015.
CIS 451: ASP Sessions and Applications Dr. Ralph D. Westfall January, 2009.
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.
ASP.NET 2.0 Chapter 6 Securing the ASP.NET Application.
ASP.NET Programming with C# and SQL Server First Edition
Chapter 11 ASP.NET JavaScript, Third Edition. 2 Objectives Learn about client/server architecture Study server-side scripting Create ASP.NET applications.
Christopher M. Pascucci Basic Structural Concepts of.NET Browser – Server Interaction.
IT533 Lectures Configuring, Deploying, Tracing and Error Handling.
McGraw-Hill/Irwin © 2004 by The McGraw-Hill Companies, Inc. All rights reserved. Beginning Active Server Pages Barry Sosinsky Valda Hilley Programming.
INTRODUCTION TO WEB DATABASE PROGRAMMING
Chapter 9 Using Perl for CGI Programming. Computation is required to support sophisticated web applications Computation can be done by the server or the.
Using Data Active Server Pages Objectives In this chapter, you will: Learn about variables and constants Explore application and session variables Learn.
8 Chapter Eight Server-side Scripts. 8 Chapter Objectives Create dynamic Web pages that retrieve and display database data using Active Server Pages Process.
CSC 2720 Building Web Applications Cookies, URL-Rewriting, Hidden Fields and Session Management.
Overview of Previous Lesson(s) Over View  Server controls are small building blocks of the graphical user interface, which includes  Text boxes  Buttons.
Overview of Previous Lesson(s) Over View  ASP.NET Pages  Modular in nature and divided into the core sections  Page directives  Code Section  Page.
IT533 Lectures Session Management in ASP.NET. Session Tracking 2 Personalization Personalization makes it possible for e-businesses to communicate effectively.
Software Architecture for ColdFusion Developers Unit 4: Application Events and Global Variables.
JavaScript, Fourth Edition
5 Chapter Five Web Servers. 5 Chapter Objectives Learn about the Microsoft Personal Web Server Software Learn how to improve Web site performance Learn.
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.
USING PERL FOR CGI PROGRAMMING
Chapter 8 Cookies And Security JavaScript, Third Edition.
Murach’s ASP.NET 4.0/VB, C1© 2006, Mike Murach & Associates, Inc.Slide 1.
Web Form Fundamentals Chapter-2 Unit-2.
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.
Lecture 8 – Cookies & Sessions SFDV3011 – Advanced Web Development 1.
1 CS 3870/CS 5870 Note04 Session Variables and Post Back.
Chapter 6 Server-side Programming: Java Servlets
Dr. Azeddine Chikh IS444: Modern tools for applications development.
Christopher M. Pascucci Basic Structural Concepts of.NET Managing State & Scope.
ASP.NET State Management. Slide 2 Lecture Overview Client state management options Cookies Server state management options Application state Session state.
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.
STATE MANAGEMENT.  Web Applications are based on stateless HTTP protocol which does not retain any information about user requests  The concept of state.
Module 7: Creating a Microsoft ASP.NET Web Application.
ASP.Net, Web Forms and Web Controls 1 Outline Session Tracking Cookies Session Tracking with HttpSessionState.
 Registry itself is easy and straightforward in implementation  The objects of registry are actually complicated to store and manage  Objects of Registry.
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.
ASP Objects Active Server Pages (cont..) 1. 2 ASP : Objects ASP provides built-in objects for performing useful tasks that simplify web development.
 Previous lessons have focused on client-side scripts  Programs embedded in the page’s HTML code  Can also execute scripts on the server  Server-side.
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3 JSP Application Models.
Understanding Web Applications Lesson 4. Objective Domain Matrix Skills/ConceptsMTA Exam Objectives Understanding Web Page Development Understand Web.
8 Chapter Eight Server-side Scripts. 8 Chapter Objectives Create dynamic Web pages that retrieve and display database data using Active Server Pages Process.
ITM © Port,Kazman 1 ITM 352 Cookies. ITM © Port,Kazman 2 Problem… r How do you identify a particular user when they visit your site (or any.
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.
7-1 Active Server and ADO Colorado Technical University IT420 Tim Peterson.
Raina NEC Application Object Describes the methods, properties, and collections of the object that stores information related to the entire Web.
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.
Alexey Polovinkin Post graduate student, CMC department.
Introduction to ASP.NET, Second Edition2 Chapter Objectives.
PHP: Further Skills 02 By Trevor Adams. Topics covered Persistence What is it? Why do we need it? Basic Persistence Hidden form fields Query strings Cookies.
111 State Management Beginning ASP.NET in C# and VB Chapter 4 Pages
Computing with C# and the .NET Framework
Session Variables and Post Back
ASP Explained By: Sarbjit Kaur.
ASP MVP Web applications and Razor
The Request & Response object
State management & Master Pages in asp.net
Anatomy of an ASP.NET Page
Configuring Internet-related services
Chapter 2 Interacting with the Customer
Web Development Using ASP .NET
Configuring .NET Web Applications
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.
PHP-II.
Presentation transcript:

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 server from the browser. Contains form and query data. Gets the HttpRequest object for the requested page.  RESPONSE: Writes HTML and other information back to the client browser. Gets the HttpResponse object associated with the Page. This object allows you to send HTTP response data to a client and contains information about that response.  SERVER: Provides server functionality for use in ASP. Gets the Server object, which is an instance of the HttpServerUtility class. Eg. using a database connection.  Global.asax and web.config are used for application control

Request  Gets the HttpRequest object for the requested page. Some properties:  ApplicationPath : Gets the ASP.NET application's virtual application root path on the server.  Browser : Gets information about the requesting client's browser capabilities.  ContentEncoding : Gets the character set of the entity-body.  Cookies : Gets a collection of cookies sent by the client.  FilePath : Gets the virtual path of the current request.  Files : Gets the collection of client-uploaded files (Multipart MIME format).  Form : Gets a collection of form variables.  Headers : Gets a collection of HTTP headers.

 HttpMethod : Gets the HTTP data transfer method (such as GET, POST, or HEAD) used by the client.  IsAuthenticated : Gets a value indicating whether the user has been authenticated.  Params : Gets a combined collection of QueryString, Form, ServerVariables, and Cookies items.  Path : Gets the virtual path of the current request.  PhysicalPath : Gets the physical file system path corresponding to the requested URL.  QueryString : Gets the collection of HTTP query string variables.  RequestType : Gets or sets the HTTP data transfer method (GET or POST) used by the client.  ServerVariables : Gets a collection of Web server variables.  Url : Gets Information about the URL of the current request.

Request Eg. browsercheck Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click Label1.Text = Request.Browser.Browser Label2.Text = Request.Browser.Version Label3.Text = Request.Browser.Platform Label4.Text = Request.Browser.Cookies End Sub

Response  Cookies : Gets the response cookie collection. Write a cookie.  Expires : Gets or sets the number of minutes before a page cached on a browser expires. If the user returns to the same page before it expires, the cached version is displayed. Expires is provided for compatibility with previous versions of ASP.  Clear() : Clears all content output from the buffer stream.  End() : Sends all currently buffered output to the client, stops execution of the page, and raises the Application_EndRequest event.  Redirect() : Overloaded. Redirects a client to a new URL. No HTML is allowed to have already be sent to the browser

Redirect example Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click Response.Redirect(“ End Sub

Server  MachineName : Gets the server's computer name.  ScriptTimeout : Gets and sets the request time-out in seconds. Default = 90  HtmlDecode() : Decodes a string that has been encoded to eliminate invalid HTML characters.  HtmlEncode() : Encodes a string/special characters like to < and > to be displayed in a browser.  UrlDecode() : Decodes a string encoded for HTTP transmission and sent to the server in a URL.  UrlEncode() : Encodes a string for reliable HTTP transmission from the Web server to a client via the URL. Eg spaces are converted to + and special characters like & to %26  Transfer() : Server.Transfer is executed on the server. The page transferred to should be another Web Forms page (.aspx page) in the same application. You cannot use Server.Transfer to redirect to an.asp or.asmx page. Server.Transfer("WebForm2.aspx")

Server Example-birthday1 <% Dim Name As string Dim Age As string Age = "twenty three??" Name = " & " Age = Server.UrlEncode(Age) Name = Server.UrlEncode(Name) %> &name=<% Response.Write(Name)%>">click here

Server Example-birthday2 <% Dim Name As string Dim Age as string Name = Request.QueryString("Name") Age = Request.QueryString("Age") Name = Server.HtmlEncode(Name) Age = Server.HtmlEncode(Age) %> Happy Birthday May the next years be as good!

Global.asax  The Global.asax also known as the ASP.NET application file is located in the root directory of an ASP.NET application  This file contains code that is executed in response to application-level and session-level events raised by ASP.NET or by HTTP modules  You can also define objects with application-wide or session-wide scope in the Global.asax file  These events and objects declared in the Global.asax are applied to all resources in that web application  The Global.asax is an optional file. Use it only when there is a need for it  You can use this file to implement application security, as well as other tasks  The Global.asax file is configured so that any direct HTTP request(via. URL) is rejected automatically, so users cannot download or view its contents

 The ASP.NET page framework recognizes automatically any changes that are made to the Global.asax file  The framework reboots the application, which includes closing all browser sessions, flushes all state information, and restarts the application domain  The Global.asax file, which is derived from the HttpApplication class, maintains a pool of HttpApplication objects, and assign them to applications as needed  There are two set of methods that fire corresponding to the events  The first set which gets invoked on each request and the second set which does not get invoked on each request  Methods corresponding to events that fire on each request : Application_BeginRequest() – fired when a request for the web application comes in Application_AuthenticateRequest() – fired just before the user credentials are authenticated. You can specify your own authentication logic over here

Application_AuthorizeRequest() – fired on successful authentication of user’s credentials. You can use this method to give authorization rights to user. Application_ResolveRequestcache() – fired on successful completion of an authorization request Application_AcquireRequestState() – fired just before the session state is retrieved for the current request Application_PreRequestHandlerExecute() – fired before the page framework begins before executing an event handler to handle the request Application_PostRequestHandlerExecute() – fired after HTTP handler has executed the request Application_ReleaseRequestState() – fired before current state data kept in the session collection is serialized Application_UpdateRequestCache() – fired before information is added to output cache of the page

Application_EndRequest() – fired at the end of each request  Methods corresponding to events that do not fire on each request : Application_Start() – fired when the first resource is requested from the web server and the web application starts Session_Start() – fired when session starts on each new user requesting a page Application_Error() – fired when an error occurs Session_End() – fired when the session of the user ends Application_End() – fired when the web application ends Application_Disposed() – fired when the web application is destroyed

Web.Config  The web.config is an XML file, it can consist of any valid XML tags, but the root element should always be  Nested within this tag you can include various other tags to describe your settings  It simply holds keys and values recognized by ASP.NET  These values are easily modifiable and you can add your own custom key and values to control other settings  ASP.NET provides a hierarchical configuration system that is very extensible, so the settings you supply in each web.config file apply only to the directory that contains the file and those below it  To provide setting for your entire application, place this file in your root application folder  Like the global.asax file, ASP.NET also prevents the web.config file from being accessed via. a Web client

 Changes to this file are automatically detected, and the application is automatically restarted for the new settings to take effect  No script blocks or HTML code, just pure XML  Inside the tags are two different elements: configuration section handlers and configuration section settings  The first section declares the types of data in the web.config file, and the second contains the actual key/value pairs of settings  Using the web.config is an ideal method of creating a robust application that can quickly adapt to changes in its environment  web.config exposes an element that can be used as a place to store application settings like connection strings, file paths etc.