Working With ASP.NET Application. Create a new virtual directory The procedure to create a new virtual directory Internet Services Manager Right click.

Slides:



Advertisements
Similar presentations
CIS 451: ASP Sessions and Applications Dr. Ralph D. Westfall January, 2009.
Advertisements

Working with Session and Application Objects. Postback and Variables Variables declared in a web page including ADO.Net objects may be reinitialized and.
Christopher M. Pascucci Basic Structural Concepts of.NET Browser – Server Interaction.
Tutorial: Introduction to ASP.NET Internet Technologies and Web Application 4 th February 2010.
Overview of Previous Lesson(s) Over View  Server controls are small building blocks of the graphical user interface, which includes  Text boxes  Buttons.
Welcome  30 Question & 30 Minutes  Question Will Move Automatically After 1 Min Your Exam Start Now Lecturer : Zalak Thakrar.
Session Tracking Dr. Awad Khalil Computer Science & Engineering Department AUC.
ASP.Net Web Applications. Characteristics of a typical data driven web application Web Server HTML Graphics Active-X Java Applets HTTP Request ADO / JDBC.
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.
INSPIRING CREATIVE AND INNOVATIVE MINDS Module 4: Adding Code to a Microsoft ASP.NET Web Form Implementing Code-Behind Pages Adding Event Procedures to.
© Minder Chen, ASP.NET 2.0: Introduction - 1 ASP.NET 2.0 Minder Chen, Ph.D. Framework Base Class Library ADO.NET: Data & XML.
Creating Custom Controls with User Controls. Including Standard Content with User Controls Global Super Company Global Super Company We mean business!
ASP.NET application. Roadmap ASP.NET file types Bin directory Application updates Simple application from start to finish using a virtual directory Behind.
Maintaining State MacDonald Ch. 9 MIS 324 MIS 324 Professor Sandvig Professor Sandvig.
1 CS 3870/CS 5870: Note 11 Authentication and Authorization Membership Provider.
Caching Chapter 12. Caching For high-performance apps Caching: storing frequently-used items in memory –Accessed more quickly Cached Web Form bypasses:
1 CS 3870/CS 5870 Note04 Session Variables and Post Back.
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3 Unit 3: Adding Code to a Microsoft ASP.NET Web Form.
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.
© Minder Chen, ASP.NET - 1 Form Handling and State Maintenance Major Build-in ASP.NET Objects Simple Form Handling HTML Forms More Complex Form.
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.
1 CS 3870/CS 5870: Note 07 Lab 3 Lab 4 Test 1: Two Tables.
Application Tracing and Error Handling. Catching Exceptions with TRY … CATCH Sub Page_Load Dim conNorthwind As SqlConnection Dim cmdSelect As SqlCommand.
Building Applications using ASP.NET and C# / Session 15 / 1 of 17 Sessio n 15.
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.
State Management. Content State Management View State Cross-Page Posting Query String Cookies Session State Application State Muzaffer DOĞAN - Anadolu.
Session 4: HTML and Web Server Controls. Outline Creating Web Forms Using Server Controls HTML Server Controls Web Server Controls Writing ASP Code Inline.
Module 1: Working with ASP.NET. Overview Introducing ASP.NET Creating Web Forms Adding ASP.NET Code to a Page Handling Page Events Discussion: ASP vs.
State Management. Agenda View state Application cache Session state ProfilesCookies.
1 CS 3870/CS 5870: Note05 Prog3 Web Application with Database.
Visual Basic.NET Programming March 3, Agenda Questions / Discussion Cookies Project Work (Ends Around 9:00 PM) Demo's (15 minutes per team)
ASP.Net, Web Forms and Web Controls 1 Outline Session Tracking Cookies Session Tracking with HttpSessionState.
Lecture Note 8: ASP Including Files and The Global.asa file.
1 CS387/CS587: Note05 Lab 3. 2 Global.asax Must not be under any sub-folder Application_Start Application_End Application_Error Session_Start Session_End.
1 CS 3870/CS 5870: Note 12 Authentication and Authorization Membership Provider.
Web Application Development Introduction. Lesson: Creating Web Forms What is a Web Form? Creating a Web Form with Visual Studio.NET.
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.
Building Applications using ASP.NET and C# / Session 5 / 1 of 19 Session 5.
CIS 375—Web App Dev II ASP.NET 4 Server Controls.
1 CS 3870/CS 5870: Note 13 Web Service. 2 What is Web Service? Providing functionality online to other Web applications SOAP Simple Object Access Protocol.
1111 Creating ASPX Controls Programatically Objectives You will be able to Dynamically add controls to a page. Dynamically alter properties of controls.
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.
1111 Creating HTML Programatically Objectives You will be able to Invoke C# code on the server from an ASP.NET page. Write C# code to create HTML.
Active Server Pages Session - 3. Response Request ApplicationObjectContext Server Session Error ASP Objects.
PLACING ORDERS- SHOPPPING CARTS. Introduction There are several stages to the order process, starting with an order page, which allows customers to add.
Sergey Sidorov PhD student, computer software chair Computer Science department.
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
Development of Internet Application 1501CT - Sara Almudauh
Computing with C# and the .NET Framework
Session Variables and Post Back
State Management.
Internet Programming Chapter 9: State Management in ASP.NET
CS 3870/CS 5870 AJAX Prog8.
ASP.NET Application Framework
Chapter 9 Web Applications
מבוא ל ASP.NET שיעור 1 : מבוא ל ASP.NET מצגת מס' 1
Session management.
Application Infrastructure
MIS Professor Sandvig MIS 324 Professor Sandvig
CS 3870/CS 5870 Test 2 (50 points) Thursday
Procedure for adding a Trusted Site
Working with Session and Application Objects
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.
Presentation transcript:

Working With ASP.NET Application

Create a new virtual directory The procedure to create a new virtual directory Internet Services Manager Right click default Web Site and choose New Virtual Directory Provide the virtual directory with an alias Choose a physical directory Add a /bin directory (contain customer components and controls))

Using Application State Sub Page_Load Application( "PageCounter" ) += 1 lblCount.Text = Application( "pageCounter" ) End Sub BadPageCounter.aspx This page has been requested: <asp:Label ID="lblCount" Runat="Server" /> times!

Using Application State Sub Page_Load Application.Lock Application( "PageCounter" ) += 1 lblCount.Text = Application( "pageCounter" ) Application.Unlock End Sub GoodPageCounter.aspx This page has been requested: <asp:Label ID="lblCount" Runat="Server" /> times!

Using Application State Application.Remove( “ myItem ” ) Application.RemoveAll()

Using the Global.asax File Sub Application_Start Dim conNorthwind As SqlConnection Dim strSelect As String Dim dadProducts As SqlDataAdapter Dim dstProducts As DataSet conNorthwind = New SqlConnection( "Server=localhost;UID=sa;PWD=secret;Database=Northwind" ) strSelect = "Select * From Products" dadProducts = New SqlDataAdapter( strSelect, conNorthwind ) dstProducts = New DataSet() dadProducts.Fill( dstProducts, "Products" ) Context.Cache( "Products" ) = dstProducts End Sub Note: Page.Cache (for.aspx) vs. Context.Cache (For Global.asax)

Using the Global.asax File Sub Page_Load dgrdProducts.DataSource = Cache( "Products" ) dgrdProducts.DataBind() End Sub DisplayProducts.aspx <asp:DataGrid ID="dgrdProducts" Runat="Server" />

Creating and Reading Session Cookies Sub Button_Click( s As Object, e As EventArgs ) Dim objCookie As HttpCookie objCookie = New HttpCookie( txtCookieName.Text, txtCookieValue.Text ) Response.Cookies.Add( objCookie ) End Sub Sub Page_PreRender( s As Object, e As EventArgs ) Dim strKey As String For each strKey in Request.Cookies lblCookies.Text &= " " & strKey & "=" & _ Request.Cookies( strKey ).Value Next End Sub Note: session cookie is added to the browser ’ s memory but not recorded to a file

Creating and Reading Session Cookies CreateCookie.aspx Cookie Name: <asp:TextBox ID="txtCookieName" Runat="Server" /> Cookie Value: <asp:TextBox ID="txtCookieValue" Runat="Server" /> <asp:Button Text="Add Cookie!" OnClick="Button_Click" Runat="Server" /> Existing Cookies: <asp:Label ID="lblCookies" EnableViewState="False" Runat="Server" />

Creating and Reading Persistent Cookies Dim objCookie As New HttpCookie( “ myCookie ”, “ Hello!! ” ) objCookie.Expires=#12/25/2005# Response.Cookies.Add(objCookie) Dim objCookie As New HttpCookie( “ myCookie ”, “ Hello!! ” ) objCookie.ExpiresdateTime.MaxValue Response.Cookies.Add(objCookie)

Create a Cookie Dictionary Dim objCookie As HttpCookies( “ Preference ” ) objCookie.Values(“color”)=“Red” objCookie.Values(“fontface”)=“Arial” objCookie.Values(“fontsize”)=“4” Response.Cookies.Add(objCookie) If objCookie.HasKeys Then Dim strItem as String For Each strItem in objCookie.Values Response.Write( “ ” & strItem & “ = “ & objCookie.Values(strItem)) Next End If Note: objCookie.Values( “ color ” )= “ Red ” keyvalue

Using Session State Adding Items to Session State Session( “ MyItem ” ) = “ Hello!! ” Session( “ myDataSet ” ) = dstDataSet Response.Write(Session( “ myItem ” ))

Using Session State Removing Items From Session State Session.Remove( “ muItem ” )

Using Session State Starting a User Session When the first page is requested, the Web server adds the ASP.NET_SessionID Cookie to the user ’ s browser Session.NewSession=True (when a new session start) Response.Write(Session.SessionID)

Using Session State Ending a User Session Session.Timeout = 10 (not request a page for more than 10 minutes) Session.Abandon

Handling Session Events Sub Session_Start() If Application( "SessionCount" ) Is Nothing Then Application( "SessionCount" ) = 0 End If Application( "SessionCount" ) += 1 End Sub Sub Session_End() Application( "SessionCount" ) -= 1 End Sub Global.asax