ASP.NET Using C# Student Guide Revision 2.2. Object Innovations Course 416

Size: px
Start display at page:

Download "ASP.NET Using C# Student Guide Revision 2.2. Object Innovations Course 416"

Transcription

1 ASP.NET Using C# Student Guide Revision 2.2 Object Innovations Course 416

2 ASP.NET Using C# Rev. 2.2 Student Guide Information in this document is subject to change without notice. Companies, names and data used in examples herein are fictitious unless otherwise noted. No part of this document may be reproduced or transmitted in any form or by any means, electronic or mechanical, for any purpose, without the express written permission of Object Innovations. Product and company names mentioned herein are the trademarks or registered trademarks of their respective owners. Copyright 2006 Object Innovations Enterprises, LLC All rights reserved. Object Innovations Printed in the United States of America. Rev. 2.2 Copyright 2006 Object Innovations Enterprises, LLC ii

3 Table of Contents (Overview) Chapter 1 Introduction to ASP.NET Chapter 2 Web Forms Architecture Chapter 3 ASP.NET and HTTP Chapter 4 Web Applications Using Visual Studio Chapter 5 State Management and Web Applications Chapter 6 Server Controls Chapter 7 Caching in ASP.NET Chapter 8 ASP.NET Configuration and Security Fundamentals Chapter 9 Debugging, Diagnostics and Error Handling Chapter 10 More Server Controls Chapter 11 Data Access in ASP.NET 2.0 Chapter 12 Personalization and Security Chapter 13 HTTP Pipeline Chapter 14 Database Programming Using ADO.NET Chapter 15 Introduction to Web Services Appendix A Learning Resources Appendix B Configuring IIS for ASP.NET 2.0 Rev. 2.2 Copyright 2006 Object Innovations Enterprises, LLC iii

4 Directory Structure The course software installs to the root directory c:\oic\aspcs. Example programs for each chapter are in named subdirectories of chapter directories Chap01, Chap02, and so on. The Labs directory contains one subdirectory for each lab, named after the lab number. Starter code is frequently supplied, and answers are provided in the chapter directories. The CaseStudy directory contains case studies in multiple steps. The Demos directory is provided for doing in-class demonstrations led by the instructor. Data files install to the directory c:\oic\data. Log files are written to the directory c:\oic\logs. Rev. 2.2 Copyright 2006 Object Innovations Enterprises, LLC iv

5 Table of Contents (Detailed) Chapter 1 Introduction to ASP.NET... 1 Web Application Fundamentals... 3 Setting up the Web Examples... 4 Creating a Virtual Directory... 7 Home Page for ASP.NET Examples... 9 From ASP to ASP.NET Limitations of ASP Benefits of ASP.NET ASP Example ASP.NET Example An Echo Program ASP.NET Features Compiled Code Server Controls Browser Independence Separation of Code and Content State Management Lab Summary Chapter 2 Web Forms Architecture Web Forms Architecture Code-Behind Version of Echo Example HelloCodebehind.aspx HelloCodebehind.aspx.cs Page Class Inheriting from Page Class Web Forms Page Life Cycle View State Web Forms Event Model Page Processing Page Events Page Properties Sample Program Page Directive Tracing Code-Behind in ASP.NET ASP.NET 2.0 Code-Behind Example ASP.NET 2.0 Code-Behind Page Lab Summary Chapter 3 ASP.NET and HTTP Rev. 2.2 Copyright 2006 Object Innovations Enterprises, LLC v

6 Classical Web Programming Active Server Pages Object Model Request and Response Objects Request and Response Example HTML Code ASP Code Request/Response in ASP.NET HttpRequest Class Properties of HttpRequest Using HttpRequest Class HTTP Collections HttpResponse Class Redirect HttpUtility Echo Program in ASP.NET Echo.aspx EchoBack.aspx GET and POST Compared QueryString and Forms Collections Lab Summary Chapter 4 Web Applications Using Visual Studio Using Visual Studio Visual Web Developer Visual Web Developer Demo Using Components in ASP.NET Compilation Error Shadow Copying Shadow Copy Demonstration Temporary Copy of the Component ASP.NET Applications Sessions Global.asax Web Application Life Cycle Application Life Cycle Example Global.asax Log Class Sample Log File StringStore Class Data Binding Data Binding Code Example Session Data Sessions Using IIS Absolute Positioning Adding Global.asax File Rev. 2.2 Copyright 2006 Object Innovations Enterprises, LLC vi

7 Lab Summary Chapter 5 State Management and Web Applications Session and Application State Example Program Session Object Page_Load Session Variable Issues Session State and Cookies Session State Timeout Session State Store Application State Implementing Application State Global.asax Users.aspx.cs Multithreading Issues Bouncing the Web Server Lab 5A Cookies Cookies and ASP.NET HttpCookie Properties Example Exposing Cookies Acme Travel Agency Case Study Lab 5B Summary Chapter 6 Server Controls Server Controls in ASP.NET HTML Server Controls Using HTML Server Controls HTML vs. Web Forms Server Controls Server Control Examples HTML Controls Example Code for Login HTML Controls in Visual Studio Using HTML Controls Web Controls Validation Controls Required Field Validation Regular Expression Validation Rich Controls Copying a Web Site Lab User Controls Using a User Control Rev. 2.2 Copyright 2006 Object Innovations Enterprises, LLC vii

8 Copyright.ascx Copyright.ascx.cs User Control Example Summary Chapter 7 Caching in ASP.NET Introduction What is Caching? Need for Caching (Why Cache?) Data to be Cached Time Frame ASP vs. ASP.NET Response Model Caching in ASP.NET Three Types of Caching in ASP.NET Output Caching... OutputCache Directive Simple Output Caching Example... OutputCache Attributes in Detail VaryByParam in Detail HttpCachePolicy Class HttpCachePolicy Class Example Page Fragment Caching Common Mistakes in Using Fragment Caching Fragment Caching Example Data Caching or Application Caching Add an Item to the Cache Object Insert and Add Methods Application Caching Example Expiration Problems in Caching Lab Summary Chapter 8 ASP.NET Configuration and Security Fundamentals One-minute Introduction to XML! ASP.NET Configuration - Overview Multi-level Configuration Configuration Hierarchy Example of Configuration Hierarchy Web.Config File Structure Web.Config Sections Application Settings ASP.NET Security Overview Role-Based Security and CAS Types and Steps Steps in Enabling Role-Based Security Three Ways to Authenticate Rev. 2.2 Copyright 2006 Object Innovations Enterprises, LLC viii

9 Forms Authentication Example Forms Authentication Default.aspx Forms Authentication Web.Config Features of Forms Authentication Forms Authentication Classes Customizing Forms Authentication Authentication Source Forms Authentication Analysis Windows Authentication Windows Authentication Analysis Windows Authentication Example Example Corrected Passport Authentication Passport Authentication - Analysis Authorization Lab Summary Chapter 9 Debugging, Diagnostics and Error Handling ASP.NET Diagnostics Debugging Using Visual Studio Calculator Example Debugging Calculator Application-Level Tracing Tracing Calculator Using the Page Cache An ASP.NET Page Without Visual Studio Attaching to VS Debugger Preparing to Debug Trace Messages Tracing the Calculator Page Conditional Tracing Trace Category Trace Warning Exceptions in Trace Errors in ASP.NET Uncaught Exception Custom Error Pages Lab Summary Chapter 10 More Server Controls ASP.NET 2.0 Control Improvements New Controls in ASP.NET Master Pages Master Page Demonstration Rev. 2.2 Copyright 2006 Object Innovations Enterprises, LLC ix

10 Using a Menu Control Creating Content Pages TreeView Control Master Page Application Visual Studio 2005 Solutions Lab Summary Chapter 11 Data Access in ASP.NET Data Access in ASP.NET AcmePub Database Creating a Connection Using Database Explorer Performing Queries Data Access Demonstration Data Entry Demonstration SQL Generation Options Enable Edit and Delete Editing Records GridView Control DetailsView Control Storing the Connection String Protecting the Configuration String Lab 11A FormView Control Master/Detail Web Pages Data Binding Template Editing Using XML Data Example Program XML Data Source Demo Multiple-Tier Data Access Object Data Source Lab 11B Summary Chapter 12 Personalization and Security Themes Control Skins Sample Skin File Applying Themes Example of Themes Security in ASP.NET ASP.NET Membership Login Controls Membership Demonstration Rev. 2.2 Copyright 2006 Object Innovations Enterprises, LLC x

11 Web Site Administration Tool Access Rules Login Controls Demo Running the Membership Demo Lab 12A Profile Properties Profile Demonstration Using ASP.NET Profile Properties Web Parts Web Parts Control Set UI Structural Components Web Parts Demonstration Lab 12B Summary Chapter 13 HTTP Pipeline Web Applications ASP.NET Request Processing ASP.NET Architecture with IIS Pipeline Processing Pipeline Architecture Customizing the HTTP Pipeline Customizing Applications Customizing a Welcome Application Logger Class Custom Handlers IHttpHandler Interface Custom Handler Example Custom Handler Configuration Custom Handler Demonstration Entry in Configuration File Extension Mapping in IIS ashx Files string.ashx Custom Modules Example: DemoModule Using DemoModule Lab Summary Chapter 14 Database Programming Using ADO.NET ADO.NET ADO.NET Architecture NET Data Providers Programming with ADO.NET Interfaces NET Namespaces Rev. 2.2 Copyright 2006 Object Innovations Enterprises, LLC xi

12 Connected Data Access Sample Database Example: Connecting to SQL Server ADO.NET Class Libraries Using Commands Creating a Command Object ExecuteNonQuery Using a Data Reader Data Reader: Code Example Data Bound Controls DataGrid in Visual Studio Binding a DataReader to a DataGrid Lab 14A Disconnected Datasets Data Adapters Command Builder Sample Application: Disconnected Main Program Creating a Data Adapter and Generating Commands Filling the Dataset Displaying the Data Set Adding a Row to the Data Set Deleting a Row Changing a Row Updating the Database Creating a Dataset Manually Using XML Data XML Schema and Data Using XML with a DataSet XMLExample Lab 14B Summary Chapter 15 Introduction to Web Services ASP.NET and Web Services Industry Standards Web Services and Remoting XML XML Namespaces Uniform Resource Identifier XML Schema SOAP WSDL Web Services Architecture A Simple Web Service The Add Web Service Example Rev. 2.2 Copyright 2006 Object Innovations Enterprises, LLC xii

13 Simple IE Client Program HTTP GET Web Service Client IE Web Form SOAP Web Service SOAP Description Viewing WSDL Demo: Creating a Client Program Anonymous Access Visual Studio Web Service Demo Hello World Web Service WS-I Basic Profile Test Client Providing a Namespace Running the Test Client Lab 15A Lab 15B Summary Appendix A Learning Resources Appendix B Configuring IIS for ASP.NET ASP.NET Versions Side-by-Side Configuring for ASP.NET Installing ASP.NET Rev. 2.2 Copyright 2006 Object Innovations Enterprises, LLC xiii

14 Rev. 2.2 Copyright 2006 Object Innovations Enterprises, LLC xiv

15 AspCs Chapter 1 Chapter 1 Introduction to ASP.NET Rev. 2.2 Copyright 2006 Object Innovations Enterprises, LLC 1

16 AspCs Chapter 1 Introduction to ASP.NET Objectives After completing this unit you will be able to: Review the fundamentals of Web applications and set up a testbed using Internet Information Services and ASP.NET. Explain the benefits of ASP.NET and outline its improvements over ASP. Describe the two programming models provided by ASP.NET, Web Forms and Web services. Create a simple Web Forms application using the.net Framework SDK. Outline the principal features of ASP.NET. Rev. 2.2 Copyright 2006 Object Innovations Enterprises, LLC 2

17 AspCs Chapter 1 Web Application Fundamentals A Web application consists of document and code pages in various formats. The simplest kind of document is a static HTML page, which contains information that will be formatted and displayed by a Web browser. An HTML page may also contain hyperlinks to other HTML pages. A hyperlink (or just link ) contains an address, or a Uniform Resource Locator (URL), specifying where the target document is located. The resulting combination of content and links is sometimes called hypertext and provides easy navigation to a vast amount of information on the World Wide Web. Rev. 2.2 Copyright 2006 Object Innovations Enterprises, LLC 3

18 AspCs Chapter 1 Setting up the Web Examples All the example programs for this chapter are in the chapter folder Chap01 underneath the root folder \OIC\AspCs. To run the examples, you will need to have Internet Information Services (IIS) installed on your system. IIS is installed by default with Windows 2000 Server. You will have to explicitly install it with Windows 2000 Workstation or Windows XP. Once installed, you can access the documentation on IIS through Internet Explorer via the URL which will redirect you to the starting IIS documentation page. The management tool for IIS is a Microsoft Management Console (MMC) snap-in, the Internet Services Manager, which you can find under Administrative Tools in the Control Panel. Rev. 2.2 Copyright 2006 Object Innovations Enterprises, LLC 4

19 AspCs Chapter 1 Setting up the Web Examples (Cont d) The figure shows the main window of the Internet Services Manager. You can Start and Stop the Web server and perform other tasks by right-clicking on Default Web Site. Choosing Properties from the context menu will let you perform a number of configurations on the Web server. The home directory for the default web site is \Inetpub\wwwroot on the drive where Windows is installed. You can change this home directory using Internet Services Manager. Rev. 2.2 Copyright 2006 Object Innovations Enterprises, LLC 5

20 AspCs Chapter 1 Setting up the Web Examples (Cont d) You can access Web pages stored at any location on your hard drive by creating a virtual directory. An easy way to create one is from Windows Explorer. Rightclick over the desired directory, choose Properties..., select the Web Sharing tab, click on the Add button, and enter the desired alias, which will be the name of the virtual directory. The figure on the next page illustrates creating an alias AspCs, or virtual directory, for the folder \OIC\AspCs. You should perform this operation now on your own system in order that you may follow along as the course examples are discussed. Rev. 2.2 Copyright 2006 Object Innovations Enterprises, LLC 6

21 AspCs Chapter 1 Creating a Virtual Directory Rev. 2.2 Copyright 2006 Object Innovations Enterprises, LLC 7

22 AspCs Chapter 1 Setting up the Web Examples (Cont d) Once a virtual directory has been created, you can access files in it by including the virtual directory in the path of the URL. In particular, you can access the file default.htm using the URL The file default.htm contains a home page for all the ASP.NET example programs for this chapter. See the figure on the next page. Rev. 2.2 Copyright 2006 Object Innovations Enterprises, LLC 8

23 AspCs Chapter 1 Home Page for ASP.NET Examples Rev. 2.2 Copyright 2006 Object Innovations Enterprises, LLC 9

24 AspCs Chapter 1 From ASP to ASP.NET ASP has been a very successful tool for creating Web applications, but there are some significant limitations. ASP.NET is not an incremental enhancement to ASP but a whole new programming environment, built on the robust foundation of the.net Framework. ASP.NET is not upwardly compatible with ASP but can run side-by-side with ASP. ASP pages have the extension.asp and ASP.NET pages have the extension.aspx. A Web site can consist of a mixture of various page types, including.html,.asp,.aspx, and so forth. ASP and ASP.NET pages will be processed separately by the appropriate runtime. ASP.NET introduces a new programming model, Web Forms, for building Web applications. ASP.NET also introduces another programming model, Web services. Web services make it possible for a Web site to expose functionality via an API that can be called remotely by other applications. The core infrastructure functionality of ASP.NET applies to both Web Forms and Web services. Rev. 2.2 Copyright 2006 Object Innovations Enterprises, LLC 10

25 AspCs Chapter 1 Limitations of ASP ASP uses scripted languages, such as VBScript and JScript. Scripted languages are interpreted and thus slower. Scripted languages lack strong data types and object-oriented features. ASP leads to intermingled HTML and script code. This mixture of HTML and code makes it hard to partition Web page development between designers, concerned with Web page appearance, and programmers, concerned with implementing logical functionality. Extensive coding is required with ASP, with limited ability to simply reuse existing components. Server-side includes and COM components can be used, but these do not provide a clean, general approach to code reuse. Dealing with browser differences has to be handled in code, leading to considerable complexity if you truly want to be browser-independent. New devices such as PDAs and cell phones make this problem worse. Rev. 2.2 Copyright 2006 Object Innovations Enterprises, LLC 11

26 AspCs Chapter 1 Benefits of ASP.NET You can use compiled, object-oriented languages with ASP.NET, including C# and Visual Basic. All the power of the.net Framework is available to you, including the extensive class library. Code and presentation elements can be cleanly separated. Code can be provided in a separate section of a Web page from user interface elements. The separation can be carried a step further by use of separate code behind files. ASP.NET comes with an extensive set of server controls that provide significant functionality out of the box. Server controls transparently handle browser compatibility issues. A special set of Mobile Controls can emit either HTML or WML, depending on the characteristics of the client device. Configuration is handled by XML files without need of any registry settings, and deployment can be done simply by copying files. Visual Studio provides a very powerful and easy-touse environment for developing and debugging Web applications. Rev. 2.2 Copyright 2006 Object Innovations Enterprises, LLC 12

27 AspCs Chapter 1 ASP Example Our example 1 displays data from a database. See OIC\AspCs\Chap01\Acme.asp. The Access database is OIC\Data\SimpleAcme.mdb. The example illustrates both the power and limitations of ASP. The language is VBScript. ADO is used for accessing the database, reading the data into a recordset. Code and HTML elements are interspersed. Code has to be provided to build up the HTML table. Note that we sometimes show long strings as simply wrapping to successive lines. They appear on a single line in code files. 1 Based on Professional ASP.NET by Richard Anderson, et al., Wrox Press, 2001, p. 22. Rev. 2.2 Copyright 2006 Object Innovations Enterprises, LLC 13

28 AspCs Chapter 1 ASP Example (Cont d) <%@ language="vbscript" %> <html> <head></head> <body> Hello, ASP <% Dim rs Dim fld Set rs = Server.CreateObject("ADODB.Recordset") rs.open "select * from Model", "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:/OIC/Data/SimpleAcme.mdb" If Not rs.eof Then Response.Write "<table border='1'><tr>" For Each fld In rs.fields Response.Write "<td>" & fld.name & "</td>" Next Response.Write "</tr>" While Not rs.eof Response.Write "<tr>" For Each fld In rs.fields Response.Write "<td>" & fld.value & "</td>" Next Response.Write "</tr>" rs.movenext Wend Response.Write "</table>" End If %> </body> </html> Rev. 2.2 Copyright 2006 Object Innovations Enterprises, LLC 14

29 AspCs Chapter 1 ASP.NET Example We do the same example in ASP.NET. See Chap01\Acme.aspx. The DataGrid server control creates an HTML table. <!-- Acme.aspx --> <%@ Page Language="C#" Debug="true" %> <%@ Import Namespace="System.Data.OleDb" %> <HTML> <HEAD> <SCRIPT RUNAT="SERVER"> void Page_Load(object source, EventArgs e) string connstr Source=c:/OIC/Data/SimpleAcme.mdb"; OleDbConnection conn = new OleDbConnection(connstr); conn.open(); OleDbCommand cmd = new OleDbCommand( "select * from Account", conn); DataGrid1.DataSource = cmd.executereader(); DataGrid1.DataBind(); } </SCRIPT> </HEAD> <BODY> Hello, ASP.NET <asp:datagrid id="datagrid1" runat="server"/> </FORM> </BODY> </HTML> This page is an example of a Web Form. Rev. 2.2 Copyright 2006 Object Innovations Enterprises, LLC 15

30 AspCs Chapter 1 An Echo Program We examine the next example, Hello.aspx, in detail. The example is complete in one file and contains embedded server code. ASP.NET pages have a.aspx extension. The source code consists of HTML along with some C# script code. There are also some special tags for server controls, recognized by ASP.NET. <!-- Hello.aspx --> <%@ Page Language="C#" %> <HTML> <HEAD> <SCRIPT RUNAT="SERVER"> void cmdecho_click(object source, EventArgs e) lblgreeting.text="hello, " + txtname.text; } </SCRIPT> </HEAD> <BODY> <FORM RUNAT="SERVER">Your name: <asp:textbox id=txtname Runat="server"></asp:textbox> <p><asp:button id=cmdecho onclick=cmdecho_click Text="Echo" runat="server" tooltip="click to echo your name"> </asp:button></p> <asp:label id=lblgreeting runat="server"></asp:label> <P></P> </FORM> </BODY> </HTML> Rev. 2.2 Copyright 2006 Object Innovations Enterprises, LLC 16

31 AspCs Chapter 1 An Echo Program (Cont d) You can run the program using the URL or by clicking on the link Chap01/Hello.aspx in the home page of the examples programs. The page shows a text box where you can type in your name, and there is an Echo button. Clicking the button will echo your name back, with a Hello greeting. The simple form is again displayed, so you could try out other names. If you slide the browser s mouse cursor over the button, you will see the tool tip Click to echo your name displayed in a yellow box. Rev. 2.2 Copyright 2006 Object Innovations Enterprises, LLC 17

32 AspCs Chapter 1 An Echo Program (Cont d) The figure illustrates a run of this example. This little program would not be completely trivial to implement with other Web application tools, including ASP. The key user interface feature of such an application is its thoroughly forms-based nature. The user is presented with a form and interacts with the form. The server does some processing, and the user continues to see the same form. This UI model is second nature in desktop applications but is not so common in Web applications. Typically, the Web server will send back a different page. Rev. 2.2 Copyright 2006 Object Innovations Enterprises, LLC 18

33 AspCs Chapter 1 An Echo Program (Cont d) This kind of application could certainly be implemented using a technology like ASP, but the code would be a little ugly. The server would need to synthesize a new page that looked like the old page, creating the HTML tags for the original page, plus extra information sent back (such as the greeting shown at the bottom in our echo example). A mechanism is needed to remember the current data that is displayed in the controls in the form. Another feature of this Web application is that it does some client-side processing too the Echo button s tooltip displayed in a yellow box is performed by the browser. Such rich client-side processing can be performed by some browsers, such as Internet Explorer, but not others. As can be seen by the example code, with ASP.NET it is very easy to implement this kind of Web application. We will study the code in detail later. For now, just observe how easy it is! Rev. 2.2 Copyright 2006 Object Innovations Enterprises, LLC 19

34 AspCs Chapter 1 ASP.NET Features ASP.NET provides a programming model and infrastructure that facilitates developing new classes of Web applications. Part of this infrastructure is the.net runtime and framework. Server-side code is written in.net compiled languages. Two main programming models are supported by ASP.NET. Web Forms helps you build form-based Web pages. A WYSIWYG development environment enables you to drag controls onto Web pages. Special server-side controls present the programmer with an event model similar to what is provided by controls in ordinary Windows programming. Web services make it possible for a Web site to expose functionality via an API that can be called remotely by other applications. Data is exchanged using standard Web protocols and formats such as HTTP and XML, which will cross firewalls. This module is focused on Web Forms, with an introduction to Web services in the last chapter. Rev. 2.2 Copyright 2006 Object Innovations Enterprises, LLC 20

35 AspCs Chapter 1 ASP.NET Features (Cont d) Both Web Forms and Web services can take advantage of the facilities provided by.net, such as the compiled code and.net runtime. In addition, ASP.NET itself provides a number of infrastructure services, including: state management security configuration caching tracing. Rev. 2.2 Copyright 2006 Object Innovations Enterprises, LLC 21

36 AspCs Chapter 1 Compiled Code Web Forms (and Web services) can be written in any.net language that runs on top of the common language runtime, including C#, Visual Basic, JScript.NET, and Visual C++. This code is compiled, and thus offers better performance than ASP pages with code written in an interpreted scripting language such as VBScript. All of the benefits, such as a managed execution environment, are available to this code, and of course the entire.net Framework Class Library is available. Legacy unmanaged code can be called through the.net interoperability services. Rev. 2.2 Copyright 2006 Object Innovations Enterprises, LLC 22

37 AspCs Chapter 1 Server Controls ASP.NET provides a significant innovation known as server controls. These controls have special tags such as <asp:textbox>. Server-side code interacts with these controls, and the ASP.NET runtime generates straight HTML that is sent to the Web browser. The result is a programming model that is easy to use and yet produces standard HTML that can run in any browser. Rev. 2.2 Copyright 2006 Object Innovations Enterprises, LLC 23

38 AspCs Chapter 1 Browser Independence Although the World Wide Web is built on standards, the unfortunate fact of life is that browsers are not compatible and have special features. A Web page designer then has the unattractive options of either writing to a lowest common denominator of browser, or else writing special code for different browsers. Server controls help remove some of this pain. ASP.NET takes care of browser compatibility issues when it generates code for a server control. If the requesting browser is upscale, the generated HTML can take advantage of these features, otherwise the generated code will be vanilla HTML. ASP.NET takes care of detecting the type of browser. Rev. 2.2 Copyright 2006 Object Innovations Enterprises, LLC 24

39 AspCs Chapter 1 Separation of Code and Content Typical ASP pages have a mixture of scripting code interspersed with HTML elements. In ASP.NET there can be a clean separation between code and presentation content. The server code can be isolated within a single <SCRIPT RUNAT="SERVER">... /SCRIPT> block or, even better, placed within a code behind page. We will discuss "code-behind" pages in the next chapter. Rev. 2.2 Copyright 2006 Object Innovations Enterprises, LLC 25

40 AspCs Chapter 1 State Management HTTP is a stateless protocol. Thus, if a user enters information in various controls on a form, and sends this filled-out form to the server, the information will be lost if the form is displayed again, unless the Web application provides special code to preserve this state. ASP.NET makes this kind of state preservation totally transparent. There are also convenient facilities for managing other types of session and application state. Rev. 2.2 Copyright 2006 Object Innovations Enterprises, LLC 26

41 AspCs Chapter 1 Lab 1 A Mortgage Calculator Web Page You have received a consulting contract to add useful functionality to a realtor s Web site. In this lab you will implement the first feature, which is a Web page that can be used to calculate a mortgage payment. Detailed instructions are contained in the Lab 1 write-up at the end of the chapter. Suggested time: 30 minutes Rev. 2.2 Copyright 2006 Object Innovations Enterprises, LLC 27

42 AspCs Chapter 1 Summary ASP.NET is a unified Web development platform that greatly simplifies the implementation of sophisticated Web applications. ASP.NET supports two programming models, Web Forms and Web services. Server controls present the programmer with an event model similar to what is provided by controls in ordinary Windows programming. Other features of ASP.NET include: Compiled code Browser independence Separation of code and content State management Security Configuration Tracing Caching Rev. 2.2 Copyright 2006 Object Innovations Enterprises, LLC 28

43 AspCs Chapter 1 Introduction Lab 1 A Mortgage Calculator Web Page You have received a consulting contract to add useful functionality to a realtor s web site. In this lab you will implement the first feature, which is a Web page that can be used to calculate a mortgage payment. The screen capture shows the completed Web page with a sample calculation. Suggested Time: 30 minutes Root Directory: OIC\AspCs Directories: Labs\Lab1 Chap01\Hello.aspx Chap01\MortgageCalculator (do your work here) (starter file) (C# mortgage calculator) Files: Chap01\Mortgage.aspx (answer) Rev. 2.2 Copyright 2006 Object Innovations Enterprises, LLC 29

44 AspCs Chapter 1 1. As a starter file, copy the file Hello.aspx into Labs\Lab1 and rename as Mortgage.aspx. You should now be able to access the echo page through the URL 2. Create the user interface for your Web mortgage calculator by making two copies of the textbox for the name in Hello. Rename the three textboxes, one button and one label appropriately. Rename the button handler to match the new name of the button. 3. Examine the code for the C# console program in the MortgageCalculator folder. Run this program a couple of times to generate some test data for use in testing your Web mortgage calculator. 4. Implement the event handler for the Calculate button by copying in code from the MortgageCalculator project. For the Web version you will obtain a numerical value by using the Convert class. For example, decimal amount; // amount of mortgage... amount = Convert.ToDecimal(txtAmount.Text); 5. After you have calculated calcpymt, display it formatted as currency in the label lblpayment. You can do the formatting by the String.Format method. lblpayment.text = String.Format("0, 8:C}", calcpymt); 6. Save your file and test it in the browser. Try out the test data obtained from running the console version of the program. Rev. 2.2 Copyright 2006 Object Innovations Enterprises, LLC 30

45 AspCs Chapter 5 Chapter 5 State Management and Web Applications Rev. 2.2 Copyright 2006 Object Innovations Enterprises, LLC 135

46 AspCs Chapter 5 State Management and Web Applications Objectives After completing this unit you will be able to: Discuss the issue of state management in creating a Web application. Explain the concept of a session and use the HttpSessionState class to manage session state. Use the HttpApplicationState class to manage application state. Use cookies to save small amounts of information persistently on clients. Implement a multiple page Web application using the features of ASP.NET discussed so far in this course. Rev. 2.2 Copyright 2006 Object Innovations Enterprises, LLC 136

47 AspCs Chapter 5 State Management and Dynamic Web Sites Static Web sites work well with the stateless HTTP protocol. Each request is for a static Web page and is independent of every other request. With dynamic Web sites the issue of state becomes important. As an example, consider the common feature of a shopping basket. The items previously selected must be remembered as the user goes from page to page on the Web site. Rev. 2.2 Copyright 2006 Object Innovations Enterprises, LLC 137

48 AspCs Chapter 5 Session and Application State Session state is information that is associated with a single browser instance visiting a Web site. The Web server identifies and classifies requests coming from a single browser client into a logical application session on the server. Session data is stored on the server for use across multiple browser requests. Session lifetime management events are raised that can be handled in application code. Application state enables sharing of global information across multiple sessions and requests within an ASP.NET application. Application state persists across requests from multiple browsers and does not disappear until there are no active browser clients (and a time interval has elapsed). Application lifetime management events are raised that can be handled in application code. There are multithreading issues with application state. Rev. 2.2 Copyright 2006 Object Innovations Enterprises, LLC 138

49 AspCs Chapter 5 Example Program The example program illustrates individual session data stored for each user. See StateDemo. Rev. 2.2 Copyright 2006 Object Innovations Enterprises, LLC 139

50 AspCs Chapter 5 Session Object You can store session information for individual users in the built-in Session object, an instance of the class HttpSessionState. You can conveniently access this object through the Session property of the Page class. The HttpSessionState class provides a key-value dictionary that you can use for storing arbitrary objects. A string is used as the key. Our example provides an illustration of the use of two session variables. UserName is a String representing the name of the user. ItemList is an ArrayList representing the list of items in the user s shopping cart. These variables are initialized in the Session_Start method of the Global class. <%@ Application Language="C#" %> <script runat="server">... void Session_Start(object sender, EventArgs e) Session["ItemList"] = new ArrayList(); Session["UserName"] = ""; }... </script> Rev. 2.2 Copyright 2006 Object Innovations Enterprises, LLC 140

51 AspCs Chapter 5 Page_Load The Page_Load method of the code-behind file for Default.aspx contains logic for storing the user name in a label control. The user name is retrieved from the session variable UserName. Note the cast to type string. If the user name is blank, there is a redirection to a login page, where the user name will be entered. protected void Page_Load(object sender, EventArgs e) string name = (string)session["username"]; if (name == "") Response.Redirect("Login.aspx"); if (!IsPostBack) lblshopper.text = name;... Rev. 2.2 Copyright 2006 Object Innovations Enterprises, LLC 141

52 AspCs Chapter 5 Event Handler for Add Button The event handler for the Add button contains code to add an item to the ArrayList of items. This list is stored as the session variable ItemList. Note the cast to type ArrayList. A helper method displays the list of items in a listbox by data binding, as discussed in Chapter protected void btnadd_click(object sender, EventArgs e) ArrayList list = (ArrayList)Session["ItemList"]; list.add(txtitem.text); ShowItems(); } private void ShowItems() ArrayList list = (ArrayList)Session["ItemList"]; listitems.datasource = list; DataBind(); } Rev. 2.2 Copyright 2006 Object Innovations Enterprises, LLC 142

53 AspCs Chapter 5 Session Variable Issues There are some interesting issues in the implementation of session variables. Typically cookies are used to identify which requests belong to a particular session. What if the browser does not support cookies, or the user has disabled cookies? There is overhead in maintaining session state for many users. Will session state expire after a certain time period? A common scenario in high-performance Web sites is to use a server farm. How can your application access its data if a second request for a page is serviced on a different machine from that on which the first request was serviced? We examine cookies later in this chapter. Rev. 2.2 Copyright 2006 Object Innovations Enterprises, LLC 143

54 AspCs Chapter 5 Session State and Cookies Although by default ASP.NET uses cookies to identify which requests belong to a particular session, it is easy to configure ASP.NET to run cookieless. In this mode the Session ID, normally stored within a cookie, is instead embedded within the URL. You will learn how to configure an application in the chapter on ASP.NET Configuration and Security. Rev. 2.2 Copyright 2006 Object Innovations Enterprises, LLC 144

55 AspCs Chapter 5 Session State Timeout By default session state times out after 20 minutes. This means that if a given user is idle for that period of time, the session is torn down; a request from the client will now be treated as a request from a new user, and a new session will be created. Again, it is easy to configure the timeout period, as we will discuss in the chapter on configuration. Rev. 2.2 Copyright 2006 Object Innovations Enterprises, LLC 145

56 AspCs Chapter 5 Session State Store ASP.NET cleanly solves the Web farm problem, and many other issues, through a session state model that separates storage from the application s use of the stored information. Thus different storage scenarios can be implemented without affecting application code. The.NET state server does not maintain live objects across requests. Instead, at the end of each Web request, all objects in the Session collection are serialized to the session state store. When the same client returns to the page, the session objects are deserialized. By default, the session state store is an in-memory cache. It can be configured to be memory on a specific machine, or to be stored in an SQL Server database. In these cases the data is not tied to a specific server, and so session data can be safely used with Web farms. Rev. 2.2 Copyright 2006 Object Innovations Enterprises, LLC 146

57 AspCs Chapter 5 Application State Application state is global information that is shared across all users of a Web application. For example, the application may keep a list of all logged in users. This list would be stored in application state. Our example program StateDemo furnishes an illustration. A Web page Users.aspx is provided to display a list of currently logged in users. You can demonstrate that the data is shared across browser sessions by bringing up another browser session and logging in. Then click the Refresh button in the first browser window. Both browser windows should then show the same list of logged in users. Rev. 2.2 Copyright 2006 Object Innovations Enterprises, LLC 147

58 AspCs Chapter 5 Implementing Application State There are several ways to implement application state. Use the built-in Application object that you can access through the Application property of the Page class. Use the built-in Cache object. Use an external data store. We illustrate the first approach in the StateDemo program. The list of users is stored as an application variable. We will discuss the Cache object in the chapter on Caching in ASP.NET. Rev. 2.2 Copyright 2006 Object Innovations Enterprises, LLC 148

59 AspCs Chapter 5 Global.asax <%@ Application Language="C#" %> <script runat="server"> void Application_Start(object sender, EventArgs e) Application["UserList"] = new ArrayList(); }... void Session_Start(object sender, EventArgs e) Session["ItemList"] = new ArrayList(); Session["UserName"] = ""; }... </script> Rev. 2.2 Copyright 2006 Object Innovations Enterprises, LLC 149

60 AspCs Chapter 5 Users.aspx.cs public partial class Users : System.Web.UI.Page protected void Page_Load(object sender, EventArgs e) ShowUsers(); } } private void ShowUsers() listusers.items.clear(); ArrayList list = (ArrayList)Application["UserList"]; foreach (string name in list) listusers.items.add(name); lblcount.text = list.count.tostring(); } protected void btnrefresh_click(object sender, EventArgs e) ShowUsers(); } Rev. 2.2 Copyright 2006 Object Innovations Enterprises, LLC 150

61 AspCs Chapter 5 Multithreading Issues Multiple threads in an application can concurrently access data stored in application state. Hence you must take care to avoid race conditions and other synchronization problems. Thread synchronization is illustrated in the Login page of the StateDemo example. The HttpApplicationState class provides methods Lock and Unlock that allow only one thread at a time to access data stored in application state. ArrayList list = (ArrayList) Application["UserList"]; Application.Lock(); list.add(txtname.text); Application.UnLock(); Rev. 2.2 Copyright 2006 Object Innovations Enterprises, LLC 151

62 AspCs Chapter 5 Bouncing the Web Server A Web application stays loaded for some time after all user activity has ceased. You can see this by old users still being logged in for the StateDemo application. You can force an application to unload by bouncing the Web server. Note that using Internet Information Services to stop the Web server does not suffice. Instead, use the Services snap-in (accessible from Administrative Tools in the Control Panel) to stop the World Wide Web Publishing service. Rev. 2.2 Copyright 2006 Object Innovations Enterprises, LLC 152

63 AspCs Chapter 5 Lab 5A Application and Session State In this lab you will completely implement the StateDemo program discussed earlier in the chapter. You will gain practice working with both application state and session state. Detailed instructions are contained in the Lab 5A write-up at the end of the chapter. Suggested time: 60 minutes Rev. 2.2 Copyright 2006 Object Innovations Enterprises, LLC 153

64 AspCs Chapter 5 Cookies A fundamental feature of the HTTP protocol is that it is stateless. We have seen that ASP.NET provides mechanisms for maintaining session information that persists across web pages. But we have not yet examined how session management is implemented. A standard mechanism used by web servers to save small amounts of information persistently is cookies. A cookie is used by the web server to save a small amount of information on the client machine. By default cookies expire as soon as the user exits the web application, but they may be set to persist until a specified expiration date. A cookie is identified by a character string name, and a cookie has a character string value. Cookies are passed as part of the HTTP header. The server requires client cooperation to set a cookie. Browsers can be set to limit or forbid use of cookies. Most users now accept cookies as harmless. Rev. 2.2 Copyright 2006 Object Innovations Enterprises, LLC 154

65 AspCs Chapter 5 Cookies and ASP.NET A cookie is written to a client machine via the HTTP response header. ASP.NET provides a class HttpCookieCollection to maintain a type-safe collection of cookies. The collection is of type NamedValueCollection, like other HTTP collections described in Chapter 3. Standard properties and methods are available for manipulating the collection. The HttpResponse classes provide a property Cookies to expose the cookies collection. Cookies are sent back to the server via the HTTP request header. Cookies themselves are represented by the class HttpCookie. A cookie has a Name and a Value, which are both strings. Constructors take either a name or both a name and a value. A cookie can also have subkeys. Domain property limits transmission of the cookie to clients requesting a resource from that domain. The Path property can extend the Domain property to completely describe the specific URL to which the cookie applies. Rev. 2.2 Copyright 2006 Object Innovations Enterprises, LLC 155

66 AspCs Chapter 5 HttpCookie Properties Additional useful properties of HttpCookie include: Expires is a DateTime (on the client) at which the cookie expires. HasKeys specifies whether a cookie has subkeys. Values is a collection of key/value pairs that can be contained within a single cookie. Items is a shortcut for Values, and in C# provides an indexer for the HttpCookie class. usercookie["name"] = txtname.text; usercookie[" "] = txt .text; Secure specifies whether to transmit the cookie securely, that is over HTTPS only. Rev. 2.2 Copyright 2006 Object Innovations Enterprises, LLC 156

67 AspCs Chapter 5 Example Exposing Cookies A demonstration program illustrates managing cookies with ASP.NET. See Cookies for all the files of the sample web application. The sample application allows you to add new cookies, delete existing cookies, and show all cookies. Rev. 2.2 Copyright 2006 Object Innovations Enterprises, LLC 157

68 AspCs Chapter 5 Example Exposing Cookies 1. Go to the page for adding a cookie, enter the name and value for the new cookie, and click the Add Cookie button. Do this two or three times. 2. Click the Home link to go back to the home page with the three buttons. Rev. 2.2 Copyright 2006 Object Innovations Enterprises, LLC 158

69 AspCs Chapter 5 Example Exposing Cookies 3. Go to the page for showing cookies. You will now see the cookies you just added among the list of cookies. Besides the cookie(s) you added yourself, there is another cookie used by the web server. Rev. 2.2 Copyright 2006 Object Innovations Enterprises, LLC 159

70 AspCs Chapter 5 Example Exposing Cookies Here is the relevant code from AddCookie.aspx: private void cmdadd_click(object sender, System.EventArgs e) HttpCookieCollection cookies; cookies = Response.Cookies; HttpCookie cookie = new HttpCookie(txtName.Text); DateTime dt = DateTime.Now; TimeSpan ts = new TimeSpan(0, 0, 30, 0); // 30 minutes cookie.expires = dt + ts; cookie.value = txtvalue.text; cookies.add(cookie); } ShowCookies.aspx uses data binding and the DataGrid control, topics which we will discuss later. Rev. 2.2 Copyright 2006 Object Innovations Enterprises, LLC 160

71 AspCs Chapter 5 Example Exposing Cookies Finally, DeleteCookie.aspx allows you to delete any cookie you don t want anymore. Rev. 2.2 Copyright 2006 Object Innovations Enterprises, LLC 161

72 AspCs Chapter 5 Example Exposing Cookies To delete a cookie, you add a cookie with existing cookie s name that expires immediately. From DeleteCookie.aspx: private void cmddelete_click(object sender, System.EventArgs e) string name = txtname.text; HttpCookieCollection reqcookies = Request.Cookies; if (reqcookies[name] == null) lblmessage.text = "Cookie " + name + " not found"; else HttpCookieCollection cookies; cookies = Response.Cookies; HttpCookie cookie = new HttpCookie(txtName.Text); cookie.expires = DateTime.Now; cookies.add(cookie); lblmessage.text = "Cookie " + name + " deleted"; } } Rev. 2.2 Copyright 2006 Object Innovations Enterprises, LLC 162

73 AspCs Chapter 5 Acme Travel Agency Case Study The Acme Travel Agency provides a Web site with online hotel reservations. Acme in turn uses the services of a hotel broker. See CaseStudy\AcmeWeb\Step2. The home page of the Web site allows a user to book reservations. Rev. 2.2 Copyright 2006 Object Innovations Enterprises, LLC 163

74 AspCs Chapter 5 Acme Travel Agency (Cont d) A second page shows all the reservations for the user and lets him cancel a selected reservation. A Windows Forms program provides the code for the hotel broker and a GUI program that exercises most of its functionality. See CaseStudy\AcmeWin\Step2. Rev. 2.2 Copyright 2006 Object Innovations Enterprises, LLC 164

75 AspCs Chapter 5 Lab 5B Acme Travel Agency Case Study In this lab you will continue the Acme Travel Agency case study begun in Lab 4. You will add a number of features: A login system to identify a user of the website, with the capability to remember a user through a cookie Capability to reserve a hotel room for a selected hotel in a selected city A reservations page that displays all reservations for the user and lets the user cancel a reservation. Detailed instructions are contained in the Lab 5B write-up at the end of the chapter. Suggested time: 90 minutes Rev. 2.2 Copyright 2006 Object Innovations Enterprises, LLC 165

76 AspCs Chapter 5 Summary Session state is information that is associated with a single browser instance visiting a Web site. Application state enables sharing of global information across multiple sessions and requests within an ASP.NET application. The Page class has properties Session and Application which give you access to HttpSessionState and HttpApplicationState classes that you can use for managing these states. ASP.NET provides several classes to facilitate working with cookies, which are a standard mechanism used by Web servers to save small amounts of information persistently on clients. Rev. 2.2 Copyright 2006 Object Innovations Enterprises, LLC 166

77 AspCs Chapter 5 Introduction Lab 5A Application and Session State In this lab you will completely implement the StateDemo program discussed earlier in the chapter. You will gain practice working with both application state and session state. Suggested Time: 60 minutes Root Directory: OIC\AspCs Directories: Labs\Lab5A Chap05\StateDemo (do your work here) (answer) Create an ASP.NET Web Application and Main Form 1. Use Visual Web Developer to create a new website StateDemo in the working directory. 2. Enter the title State Demo for the page Default.aspx. 3. Bring up the Toolbox from the View menu, if not already showing. 4. From Tools Options bring up CSS Positioning for HTML Designer. Make sure that for Positioning options you have Absolutely positioned. 5. Drag three Label controls, one textbox, one listbox, and one button onto the form, as shown in the screen capture. 6. For the three label controls, enter Text of Shopper, blank, and New Item. For the button, enter Text of Add. Rev. 2.2 Copyright 2006 Object Innovations Enterprises, LLC 167

78 AspCs Chapter 5 7. Change the (ID) of the second label to lblshopper. Change the (ID) of the textbox to txtitem, of the listbox to listitems, and of the button to btnadd. 8. If you need to make the layout of your controls neater, you can bring up the Layout toolbar by right-clicking an empty area of toolbar and selecting Layout from the context menu. You can then use the Align Left and Align top buttons to make your form neatly aligned. Implement the List of Items for Each User We are now ready to implement the list of items. Since there is a separate list for each user, we will store the list (an ArrayList) as session state. 1. Add a Global.asax file to your project. 2. In the Session_Start method of Global, initialize a session variable ItemList to a new ArrayList. 3. Add a using statement to bring in the System.Collections namespace. 4. Add a handler for the Add button. 5. In this handler do the following: a. Obtain the Object from Session[ ItemList ] and cast it to an ArrayList and store in a temporary variable list. b. Call the Add method of ArrayList to add the string in txtitem to the list. c. Bind the listbox listitems to the ArrayList list by the following code: listitems.datasource = list; DataBind(); 6. Build and test. You should now be able to add items and see them displayed in the listbox. Implement the Login Page 1. In the Session_Start method of Global, initialize a session variable UserName to an empty string. 2. Add a new Web Form by right-clicking over the project and choosing Add New Item from the context menu. Choose Web Form as the template, and have the code placed in a separate file. Make the name of your new form Login.aspx. 3. Drag one label, one textbox, and one button on to the form and change the Text property of the label and button as shown: Rev. 2.2 Copyright 2006 Object Innovations Enterprises, LLC 168

79 AspCs Chapter 5 4. Change the (ID) of the textbox to txtname, and the (ID) of the button to btnlogin. 5. Add a handler for the Login button. In the code do the following a. Assign the session variable UserName to the string entered in the textbox control. b. Redirect to Default.aspx. 6. Implement the Page_Load method of the Main class as follows: a. Store the user name in a local variable name by casting the session variable to a string. b. If this name is blank, redirect to Login.aspx. c. Otherwise, if it is not a postback, set the lblshopper label to this name. 7. Build and test. You should now be at Step 1. Implement the List of User The last step is to implement a list of logged in users. This list will be stored in application state. 1. In the Application_Start method of Global, initialize an application variable UserList to a new ArrayList. 2. Add a new Web Form Users.aspx to the project. 3. Drag a listbox, a button, a hyperlink, and two labels onto the form, as shown in the screen capture. 4. Set the properties of the listbox, button and labels in the usual way. Make the Text of the hyperlink Home, and set the NavigateUrl property to Default.aspx. Rev. 2.2 Copyright 2006 Object Innovations Enterprises, LLC 169

80 AspCs Chapter 5 5. This time, instead of binding the listbox to an ArrayList, we will populate the listbox by a different method. We want to be able to Refresh and see the result of some other users being added through a different browser client. To this end create the following helper method ShowUsers. private void ShowUsers() listusers.items.clear(); ArrayList list = (ArrayList) Application["UserList"]; foreach (string name in list) listusers.items.add(name); } 6. Add a handler for Refresh. Implement by calling ShowUsers. 7. Similarly, implement Page_Load by calling ShowUsers. 8. Modify the handler for Login in Login.aspx.cs to add the user just logged in to the list of user. private void cmdlogin_click(object sender, System.EventArgs e) Session["UserName"] = txtname.text; ArrayList list = (ArrayList) Application["UserList"]; list.add(txtname.text); Response.Redirect("Default.aspx"); } 9. Build and test. It s not quite working right, because when you go back to Main.aspx after visiting Users.aspx the list of items is lost. Fix this by adding appropriate code to Page_Load. You might find it useful to create a helper method ShowItems that can be called both by Page_Load and by the handler for the Add button. 10. You should now be able to run multiple browser clients and see the effects of several different users, each with its own list of items. (You may find it convenient to run under IIS to test this functionality. Be sure to configure the directory as an application in IIS.) 11. A final detail is to ensure thread safety when you manipulate application state. Add code to the Login handler to lock the list of users while adding a new user. protected void btnlogin_click(object sender, EventArgs e) Session["UserName"] = txtname.text; ArrayList list = (ArrayList)Application["UserList"]; Application.Lock(); list.add(txtname.text); Application.UnLock(); Response.Redirect("Default.aspx"); } Rev. 2.2 Copyright 2006 Object Innovations Enterprises, LLC 170

81 AspCs Chapter 5 Introduction Lab 5B Acme Travel Agency Case Study In this lab you will continue the Acme Travel Agency case study begun in Lab 4. You will add a number of features: A login system to identify a user of the website, with the capability to remember a user through a cookie Capability to reserve a hotel room for a selected hotel in a selected city A reservations page that displays all reservations for the user and lets the user cancel a reservation. Suggested Time: 90 minutes Root Directory: OIC\AspCs Directories: Labs\Lab5B\AcmeWeb Labs\Lab4\AcmeWeb CaseStudy\AcmeWeb\Step1 CaseStudy\AcmeWin\Step2 CaseStudy\AcmeWeb\Step2 (do your work here) (previous lab work) (backup of starter code) (source code for hotel broker) (answer) Study the Hotel Broker Code 1. Build and run the Windows Forms program in CaseStudy\AcmeWin\Step2. Experiment with making and canceling a few reservations. 2. Study the code in HotelBroker.cs. Note that we ve added data structures and methods for manipulating reservations. 3. Briefly examine the Windows Forms exerciser program. It exercises some but not all the functionality of the hotel broker. This program has a single hard-coded user, Joe. Web Page for Making Reservations 1. If you would like to use your code from Lab 4, delete the supplied starter files and copy your Lab 4 files to the working directory. 2. Copy the file HotelBroker.cs from CaseStudy\AcmeWin\Step2 to the App_Code folder in the working directory, overwriting the old file of that name. 3. Open the website in the working directory in Visual Web Developer and run it, verifying that you can list the hotels in the various cities. Rev. 2.2 Copyright 2006 Object Innovations Enterprises, LLC 171

82 AspCs Chapter 5 4. Select the four controls on Default.aspx and set the positioning to Absolute from the Layout Position menu. 5. Drag the controls downward on the form somewhat to make room for two label controls at the top of the form showing the current customer. 6. Drag additional controls onto the form from the Toolbox as shown in the screen capture. 7. Assign properties to the new controls as shown in the table. Control (ID) Text Label Customer: Label lblcustomer Label Date TextBox txtdate Label Number Days TextBox txtnumdays TextBox txtmessage Hyperlink Manage My Reservations Button btnmake Make Reservation 8. Set the TextMode property of the txtmessage text box to MultiLine. 9. Set the NavigateUrl propery of the hyperlink to Reservations.aspx, which will be a new page. 10. Add code to the Page_Load() method to initialize lblcustomer.text to Joe. (Later, we will change this code to be the name of a logged-in user.) Rev. 2.2 Copyright 2006 Object Innovations Enterprises, LLC 172

83 AspCs Chapter 5 HotelBroker in Application State In Step 1 we never changed any data maintained by the hotel broker, so it sufficed to always obtain a new HotelBroker object. Now we will be making and canceling reservations, so it will be important to always work with the same HotelBroker object. We will store it in application state. 1. Add a Global Application Class Global.asax to your application. 2. Add code to Application_Start() to initialize an application variable Broker to a new HotelBroker object. 3. Replace the code in Page_Load() that instantiated a new HotelBroker object with code to obtain the HotelBroker object that is stored in application. HotelBroker broker = (HotelBroker)Application["Broker"]; 4. Do the same thing in the handler for selecting a city from the dropdown. 5. Build and test your application. It should behave in the same manner as before, and you should see the new controls that you added. Make Reservations 1. Add a handler for the Make Reservation button. 2. Next, we re going to provide code to read and parse a date and an integer representing the number of days. If either is not correctly formatted, the exception error message should be displayed in the txtmessage text box. If the information is entered correctly, write out a debugging message using Debug.WriteLine(). You will need to bring in the System.Diagnostics namespace. The following code will accomplish the objective. DateTime date; int numdays; txtmessage.text = ""; try date = DateTime.Parse(txtDate.Text); numdays = Convert.ToInt32(txtNumDays.Text); } catch (Exception ex) txtmessage.text = ex.message; return; } Debug.WriteLine("date = " + date.toshortdatestring()); Debug.WriteLine("numDays = " + numdays); 3. Run under the debugger, and test with both valid and invalid formats for the date and number of days. Rev. 2.2 Copyright 2006 Object Innovations Enterprises, LLC 173

84 AspCs Chapter 5 4. Add code to initialize a HotelBroker object from application state and to obtain the city and hotel name from the dropdown boxes. 5. Now you can call the MakeReservation() method, obtaining back a ReservationResult. 6. If ReservationId is not -1, build up a multi-line message for txtmessage, using Environment.NewLine for the new line character, displaying the results of the reservation. 7. If ReservationId is -1, display the Comment field. The following code accomplishes the last several steps. string city = listcities.text; string hotelname = listhotels.text; HotelBroker broker = (HotelBroker)Application["Broker"]; ReservationResult result = broker.makereservation( lblcustomer.text, hotelname, city, date, numdays); string NL = Environment.NewLine; if (result.reservationid!= -1) txtmessage.text = "Reservation has been booked" + NL; txtmessage.text += "ReservationId = " + result.reservationid + ", "; txtmessage.text += "ReservationRate = " + result.rate + NL; txtmessage.text += "ReservationCost = " + result.reservationcost + NL; txtmessage.text += result.comment; } else txtmessage.text = "Reservation has not been booked" + NL; txtmessage.text += result.comment; } 8. Build and test, making several reservations. Display and Cancel Reservations 1. Add a new Web Form Reservations.aspx to your project, with code in a separate file. The new page should have title Acme Travel. Make the original Default.aspx page the start page for your project. 2. Add controls to your new page as shown in the screen capture on the following page. The small box at the top is a TextBox with (ID) of txtcustomer. The large box in the middle is a ListBox with (ID) of listres. The hyperlink should point to Default.aspx. Rev. 2.2 Copyright 2006 Object Innovations Enterprises, LLC 174

85 AspCs Chapter 5 3. Add code to Page_Load() to initialize txtcustomer.text to Joe. (Later, we will change this to be the logged-in customer.) 4. Call a helper method ShowReservations(). This code will be implemented a little differently than in the Windows Forms version, where we could store arbitrary objects in the list box. In our Web Forms version we will store a string in the list box. We want to store the reservation ID, hotel name, city, arrival date and number of days, separated by commas. We obtain the list of reservations by calling the GetReservations() method of HotelBroker. The following code does the job. private void ShowReservations() HotelBroker broker = (HotelBroker)Application["Broker"]; ArrayList array = broker.getreservations(txtcustomer.text); if (array == null) return; } ClearReservations(); foreach (Reservation item in array) string rid = item.reservationid.tostring(); string hotel = item.hotelname; string city = item.city; string arrive = item.arrivaldate.tostring("d"); string number = item.numberdays.tostring(); string str = rid + "," + hotel + "," + city + "," + arrive + "," + number; listres.items.add(str); } } private void ClearReservations() listres.items.clear(); } 5. Build and test. You should now be able to make reservations for Joe, and see these reservations. 6. Add a handler for the Cancel Selected Reservation button. Rev. 2.2 Copyright 2006 Object Innovations Enterprises, LLC 175

86 AspCs Chapter 5 7. Provide code to break the string representing the reservation into fields separated by commas. From the first field determine the reservation ID, and use this in the call to the CancelReservation() method of HotelBroker. Show the reservations. The following code will do the job. if (listres.selectedindex!= -1) string selected = listres.selecteditem.tostring(); Debug.WriteLine(selected); char[] sep = new char[] ','}; string[] fields; fields = selected.split(sep); int id = Int32.Parse(fields[0]); Debug.WriteLine(id.ToString()); HotelBroker broker = (HotelBroker)Application["Broker"]; broker.cancelreservation(id); ShowReservations(); } 8. Add a handler for the Refresh button. In this handler call ShowReservations(). 9. Build and test. You should now be able to make and cancel reservations for Joe. Since the customer name is shown in a text box, you could try entering a name other than Joe and click Refresh. The list box of reservations should then be empty. Login System Next, let s provide the capability to log a user in, and use this name in place of the hardcoded Joe. The logged-in user will be saved in session state. 1. Add a new Web Form Login.aspx to your project. Code should be in a separate file. Make the title of the page Acme Travel. 2. Add the controls shown in the screen capture. The (ID) of the text box should be txtname, and the (ID) of the checkbox chkcookie. 3. Add code to the Session_Start() method in Global.asax to initialize a session variable Customer to the empty string. 4. Add code to Page_Load() in Default.aspx.cs to retrieve the name of the customer from session state. If it is empty, redirect to Login.aspx, otherwise assign this name to lblcustomer. Rev. 2.2 Copyright 2006 Object Innovations Enterprises, LLC 176

87 AspCs Chapter 5 5. In Login.aspx, provide a handler for the Login button. In this handler, initialize the Customer session variable to the name provided in the login form. Redirect to Default.aspx. 6. In Reservations.aspx, replace the code in Page_Load that initializes txtcustomer.text with the hardcoded Joe with code that uses the Customer session variable. 7. Build and test. You should now be able to login in a customer and make/cancel reservations for that customer. Run again using the ASP.NET Web server (without closing your session of Visual Web Developer), and you can make/cancel reservations for a different customer. You can see the reservations for the previous customer by typing in the name and clicking Refresh. Use a Cookie Finally, we ll provide the capability to remember a user through a cookie. 1. Modify Page_Load() in Default.aspx to first look for the customer name in a cookie named Customer. You could use the following code. if (!IsPostBack) // Look for customer name in either cookie or session state HttpCookie cookie = Request.Cookies["Customer"]; string name; if (cookie!= null) name = cookie.value; Session["Customer"] = name; } else name = (string)session["customer"]; if (name == "") Response.Redirect("Login.aspx"); lblcustomer.text = name; 2. Modify the handler for the Login button to initialize a cookie if requested by the user. Session["Customer"] = txtname.text; if (chkcookie.checked) HttpCookie cookie = new HttpCookie("Customer"); cookie.value = txtname.text; cookie.expires = DateTime.Now.AddHours(1); Response.Cookies.Add(cookie); } Response.Redirect("Default.aspx"); 3. Build and test under the ASP.NET Development Server. Rev. 2.2 Copyright 2006 Object Innovations Enterprises, LLC 177

88 AspCs Chapter 5 4. If you have time, do further testing using Internet Information Services. Note that if you have a cookie lying around that you d like deleted, you can do so with the Cookies demonstration program! Rev. 2.2 Copyright 2006 Object Innovations Enterprises, LLC 178

89 AspCs Chapter 13 Chapter 13 HTTP Pipeline Rev. 2.2 Copyright 2006 Object Innovations Enterprises, LLC 427

90 AspCs Chapter 13 HTTP Pipeline Objectives After completing this unit you will be able to: Describe the general architecture of Web applications that generate dynamic content. Describe the architecture of the HTTP pipeline, which is used in Web Forms, Web services, and other ASP.NET applications. Outline the principal classes in ASP.NET that support the HTTP pipeline. Explain the role of context in ASP.NET applications. Customize the HTTP pipeline through the application class. Explain the use of HTTP handlers and modules. Implement custom HTTP handlers. Implement custom HTTP modules. Rev. 2.2 Copyright 2006 Object Innovations Enterprises, LLC 428

91 AspCs Chapter 13 Web Applications Originally the Web served up static content in the form of HTML pages. Web servers then simply retrieved static pages from a file store. With the advent of dynamically generated content, the architecture of Web applications became more complex. The browser makes a request for a certain URL, but the request is satisfied through a program rather than a static page. The universal protocol for invoking a program was CGI (Common Gateway Interface). The drawback of CGI is the fact that each request spawns a process, and we have the overhead of inter-process communication. In Microsoft Windows, a much more efficient protocol is ISAPI (Internet Server Application Programming Interface). ISAPI applications run as a DLL in the same process as the Web server. The file extension of the requested page is used by the Web server to determine the protocol used for dispatching the request. Rev. 2.2 Copyright 2006 Object Innovations Enterprises, LLC 429

92 AspCs Chapter 13 ASP.NET Request Processing ASP.NET running on Internet Information Services (IIS) processes requests in this general manner: IIS looks for an extension mapping for the requested page. If the extension is recognized by ASP.NET (.aspx,.asmx, and so on), IIS loads aspnet_isapi.dll and passes the request to it, using the ISAPI protocol. The ISAPI extension DLL locates the ASP.NET worker process aspnet_wp.exe and sets up named pipes for communication with it. The request is sent to the worker process to be handler. The worker process routes the request to the HTTP pipeline in an app domain that is associated with the virtual directory of the Web application. The HTTP pipeline processes the request, ultimately through a handler, which creates a response that is sent back through the same channels. This architecture, involving a worker process that is separate from the Web server, is used in IIS 5.0. See the figure on the following page. Rev. 2.2 Copyright 2006 Object Innovations Enterprises, LLC 430

93 AspCs Chapter 13 ASP.NET Architecture with IIS 5.0 Browser IIS aspnet_isapi.dll App Domain HTTP Pipeline HttpRuntime Application Other App Domains Handler aspnet_wp.exe (worker process) Each ASP.NET application is housed in its own app domain, which provides isolation without the overhead of separate processes. Rev. 2.2 Copyright 2006 Object Innovations Enterprises, LLC 431

94 AspCs Chapter 13 Pipeline Processing The HTTP pipeline processing of a request involves these steps: 1. An instance of the class HttpWorkerRequest is created, containing all the information about the request. 2. This request is passed to the ProcessRequest method of the HttpRuntime class. 3. An instance of the class HttpContext is created, keeping all the relevant information about the request together in one place, accessible throughout the pipeline. 4. Instances of HttpRequest and HttpResponse are created, stored as fields within HttpContext. 5. HttpRuntime obtains an application class (derived from HttpApplication) through HttpApplicationFactory. Either a new application instance is created, or one is pulled from a pool. 6. Modules associated with the application are created to do preand post-processing for the request. 7. HttpRuntime dispatches the request to the application class that has been created. 8. The application class locates a handler to service the request, either directly or by going through a handler factory. 9. The ProcessRequest method of the handler is invoked, passing in the current HttpContext. 10. The handler reads information from the HttpRequest field of the context and writes information to the HttpResponse field. Rev. 2.2 Copyright 2006 Object Innovations Enterprises, LLC 432

95 AspCs Chapter 13 Pipeline Architecture This diagram illustrates the architecture of the HTTP pipeline: Worker Process HttpContext HttpRuntime Application Factory Application Module Handler Factory Handler Rev. 2.2 Copyright 2006 Object Innovations Enterprises, LLC 433

96 AspCs Chapter 13 Customizing the HTTP Pipeline There are three major extensibility points for the HTTP pipeline: Through the application class, either using HttpApplication as is or deriving a new class from it. By creating a custom handler that implements the IHttpHandler interface. By creating custom modules to do pre- and post-processing of requests. Rev. 2.2 Copyright 2006 Object Innovations Enterprises, LLC 434

97 AspCs Chapter 13 Customizing Applications The HttpApplication class is central to every ASP.NET application. It serves as the initial entry point for application requests. It provides a repository of resources that are globally accessible with the application, such as application state, session state, and the cache. It offers access to many events that occur during the lifetime of an application. Often you can simply make use of the base class HttpApplication itself. You can access a reference to the class through the ApplicationInstance property of either the HttpContext class or the Page class. You may obtain further customization by deriving a class from HttpApplication. Visual Studio does this for you automatically in the Global.asax file. Rev. 2.2 Copyright 2006 Object Innovations Enterprises, LLC 435

98 AspCs Chapter 13 Customizing a Welcome Application As a simple illustration of customizing an application through the application class, let s customize a welcome application. See the Welcome folder in the chapter directory. The core application simply displays a welcome message in bold. <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" " transitional.dtd"> <html xmlns=" > <head runat="server"> <title>application Demo</title> </head> <body> <form id="form1" runat="server"> <div> <b>welcome to ASP.NET</b> </div> </form> </body> </html> Rev. 2.2 Copyright 2006 Object Innovations Enterprises, LLC 436

99 AspCs Chapter 13 Welcome Application (Cont d) The code-behind file has no added code. public partial class _Default : System.Web.UI.Page protected void Page_Load(object sender, EventArgs e) } } If we run the application, we see additional output: If you use IIS, be sure to configure the Welcome directory as an application in IIS! Rev. 2.2 Copyright 2006 Object Innovations Enterprises, LLC 437

100 AspCs Chapter 13 Welcome Application (Cont d) The code for the additional output is provided by event handlers in the application class. void Application_Start(Object sender, EventArgs e) WriteLine("Application starting"); Context.Items["AppStart"] = DateTime.Now; log = new Application["Log"] = log; log.open(); log.write("application starting"); log.write(datetime.now.tolongtimestring()); } void Session_Start(Object sender, EventArgs e) WriteLine("Session starting"); Context.Items["SessionStart"] = DateTime.Now; log = new Application["Log"] = log; log.open(); log.write("session starting"); log.write(datetime.now.tolongtimestring()); } Rev. 2.2 Copyright 2006 Object Innovations Enterprises, LLC 438

101 AspCs Chapter 13 Welcome Application (Cont d) void Application_BeginRequest(Object sender, EventArgs e) log = (Logger) Application["Log"]; WriteLine("Request starting"); Context.Items["RequestStart"] = DateTime.Now; log.write("request starting"); log.write(datetime.now.tolongtimestring()); } void Application_EndRequest(Object sender, EventArgs e) log = (Logger) Application["Log"]; WriteLine("Request ending"); DateTime start = (DateTime) Context.Items["RequestStart"]; TimeSpan ts = DateTime.Now - start; WriteLine(ShowTime(ts)); log.write("request ending"); log.write(datetime.now.tolongtimestring()); log.write(showtime(ts)); }... Rev. 2.2 Copyright 2006 Object Innovations Enterprises, LLC 439

102 AspCs Chapter 13 Welcome Application (Cont d) Helper methods are provided to display elapsed time and to also provide logging to a file. private Logger log; private void WriteLine(string text) Context.Response.Write(text); Context.Response.Write("<br>"); } private string ShowTime(TimeSpan ts) return string.format( "0} minutes, 1} seconds, 2} milliseconds", ts.minutes, ts.seconds, ts.milliseconds); } Here is some sample log file output: Application starting 9:19:42 AM Request starting 9:19:42 AM Session starting 9:19:42 AM Request ending 9:19:43 AM 0 minutes, 0 seconds, 781 milliseconds Rev. 2.2 Copyright 2006 Object Innovations Enterprises, LLC 440

103 AspCs Chapter 13 Logger Class The Logger class provides a simple logging mechanism. using System.IO; public class Logger private string m_path; private StreamWriter m_writer; public Logger(string path) m_path = path; } public void Open() FileStream fs; if (File.Exists(m_path)) fs = new FileStream(m_path, FileMode.Append, FileAccess.Write, FileShare.ReadWrite); } else fs = new FileStream(m_path, FileMode.Create, FileAccess.Write, FileShare.ReadWrite); } m_writer = new StreamWriter(fs); m_writer.writeline(" "); } } Rev. 2.2 Copyright 2006 Object Innovations Enterprises, LLC 441

104 AspCs Chapter 13 Logger Class (Cont d) } public void Close() m_writer.close(); } public void Write(string text) m_writer.writeline(text); m_writer.flush(); } Rev. 2.2 Copyright 2006 Object Innovations Enterprises, LLC 442

105 AspCs Chapter 13 Custom Handlers Web Forms with a Page class rely on a handler provided by ASP.NET for files with a.aspx extension. A handler must implement the IHttpHandler interface. public interface IHttpHandler void ProcessRequest(HttpContext context); bool IsReusable get;} } The Page class implements this interface. Its implementation of ProcessRequest() writes a response by rendering the controls within the page. You can create your own handler that is not tied into the rendering based on controls provided by the Page class. Create a class that implements the IHttpHandler interface. Hook your handler class to the application through the IIS extension mapping mechanism and the configuration file of your application. Rev. 2.2 Copyright 2006 Object Innovations Enterprises, LLC 443

106 AspCs Chapter 13 IHttpHandler Interface public interface IHttpHandler void ProcessRequest(HttpContext context); bool IsReusable get;} } The ProcessRequest() method takes the context of the request as input and performs the servicing of the request. The IsReusable property is used to indicate whether instances of a handler can be pooled. Usually, you would return false, indicating that your handler is not pooled. It might make sense to provide for handler pooling if there is significant overhead in setting up a handler. Rev. 2.2 Copyright 2006 Object Innovations Enterprises, LLC 444

107 AspCs Chapter 13 Custom Handler Example As an example of a custom handler, examine the class library StringLib in the chapter directory, defining the class StringHandler. namespace StringLib public class StringHandler : IHttpHandler public void ProcessRequest(HttpContext ctx) string s = ctx.request["p"]; string op = ctx.request["op"]; switch (op) case "echo": ctx.response.write("hello, " + s); break; case "upper": ctx.response.write(s.toupper()); break; default: ctx.response.write( "Illegal operation"); break; } } public bool IsReusable get return false; } } } } Rev. 2.2 Copyright 2006 Object Innovations Enterprises, LLC 445

108 AspCs Chapter 13 Custom Handler Example (Cont d) This handler supports two different operations on strings: echo will return a greeting Hello, <p>, echoing whatever is entered as the p parameter upper will convert the string in the p parameter to upper case. The operation itself is specified by the op parameter. The parameters are passed using ordinary parameter notation for GET requests. Here is a sample URL: op=echo&p=handler And here is the corresponding output: Rev. 2.2 Copyright 2006 Object Innovations Enterprises, LLC 446

109 AspCs Chapter 13 Custom Handler Configuration The intricate part of working with custom handlers is not the code but doing the configuration required to make them work. Here is a summary of the steps: 1. Make the folder containing the target page an application in IIS. 2. Copy the DLL containing the handler into the bin subdirectory. 3. Add an entry to the Web.config file for our application within the httphandlers section. 4. Configure IIS to map the desired file extension into aspnet_isapi.dll. Rev. 2.2 Copyright 2006 Object Innovations Enterprises, LLC 447

110 AspCs Chapter 13 Custom Handler Demonstration Let s illustrate this configuration by wiring up the StringHandler example to run within a folder in the Demos directory. 1. Create a folder StringPage in the Demos directory. 2. Inside this folder create a file page.str with arbitrary text in it. 3. Access this page using Internet Explorer and this URL: You should see the text of the file displayed. 4. Create a bin subfolder. Build the DLL in the StringLib project and copy StringLib.dll into it. 5. Make the StringPage folder an application in IIS. Rev. 2.2 Copyright 2006 Object Innovations Enterprises, LLC 448

111 AspCs Chapter 13 Entry in Configuration File 6. Create a Web.config file with an appropriate entry for httphandlers. (You could just copy the file from the StringPage folder in the chapter directory.) <?xml version="1.0" encoding="utf-8"?> <configuration> <system.web> <httphandlers> <add verb="get" path="*.str" type="stringlib.stringhandler, StringLib" /> </httphandlers> </system.web> </configuration> The verb list can be a comma-separated list of HTTP verbs or a wildcard *. The path attribute can be either a single URL path or else a path containing a wildcard. The type attribute is a comma-separated list class/assembly pair. The ASP.NET runtime searches for the assembly first in the application s private bin folder and then in the general assembly cache. Rev. 2.2 Copyright 2006 Object Innovations Enterprises, LLC 449

112 AspCs Chapter 13 Extension Mapping in IIS 7. The final step is to configure the extension in IIS. In Internet Services Manager right-click over Default Web Site and choose Properties. Select the Home Directory tab. 8. Click the Configuration button. Rev. 2.2 Copyright 2006 Object Innovations Enterprises, LLC 450

113 AspCs Chapter 13 Extension Mapping in IIS (Cont d) 9. The Application Configuration dialog comes up. 10. Click Add. Rev. 2.2 Copyright 2006 Object Innovations Enterprises, LLC 451

114 AspCs Chapter 13 Extension Mapping in IIS (Cont d) 11. The Add/Edit Application Extension Mapping Dialog comes up. Click Browse and find aspnet_isapi.dll in the WINDOWS\Microsoft.NET\Framework directory under a folder for the current version of.net. 12. Type in the desired extension, in this case.str. 13. Click OK, OK, and OK. The new extension mapping should now be all set up. 14. Now again try to access page.str. Now the result will be different, with output generated by the custom handler. Rev. 2.2 Copyright 2006 Object Innovations Enterprises, LLC 452

115 AspCs Chapter 13 Custom Handler Demo (Cont d) 15. Experiment with different parameters, using GET parameter syntax in the URL. Here is echo for a person s name. 16. And here is the upper operation. 17. Our small custom handler demonstration is now complete. Rev. 2.2 Copyright 2006 Object Innovations Enterprises, LLC 453

116 AspCs Chapter 13.ashx Files ASP.NET provides a special extension.ashx that can be used to implement a custom handler without the configuration steps required for a custom extension. Such a page requires two features: A WebHandler directive with a Class attribute. The class identified by the Class attribute must implement the IHttpHandler interface. For an example, see the file string.ashx at the toplevel of the chapter directory. This example implements the same logic as our StringLib custom handler. The code is complete in one file, as shown on the following page. Rev. 2.2 Copyright 2006 Object Innovations Enterprises, LLC 454

117 AspCs Chapter 13 string.ashx <!-- string.ashx -> WebHandler Language="C#" Class="StringHandler" %> using System; using System.Web; public class StringHandler : IHttpHandler public void ProcessRequest(HttpContext ctx) string s = ctx.request["p"]; string op = ctx.request["op"]; switch (op) case "echo": ctx.response.write("hello, " + s); break; case "upper": ctx.response.write(s.toupper()); break; default: ctx.response.write("illegal operation"); break; } } public bool IsReusable get return false; } } } Rev. 2.2 Copyright 2006 Object Innovations Enterprises, LLC 455

118 AspCs Chapter 13 Custom Modules The third major extensibility feature of the HTTP pipeline is the module. A module is created the first time the application itself is created and exists as long as the application exists. A module can hook into any of the HttpApplication events. A module is typically used to perform pre- and postprocessing on requests (similar to ISAPI filters). There are two basic steps to using modules: Create a class that implements the IHttpModule interface and copy the DLL to the bin folder of the application using the module. Add a <httpmodules> section to the configuration file of the application. <?xml version="1.0" encoding="utf-8"?> <configuration> <system.web> <httpmodules> <add name="prepostmodule" type="demomodule.prepost, DemoModule" /> </httpmodules> </system.web> </configuration> Rev. 2.2 Copyright 2006 Object Innovations Enterprises, LLC 456

119 AspCs Chapter 13 Example: DemoModule namespace DemoModule public class PrePost : IHttpModule public void Init(HttpApplication app) app.beginrequest += new EventHandler(app_BeginRequest); app.endrequest += new EventHandler(app_EndRequest); } public void Dispose() } private void app_beginrequest(object sender, EventArgs e) HttpApplication app = sender as HttpApplication; app.context.response.write("beginning..."); app.context.response.write("<br>"); } } } private void app_endrequest(object sender, EventArgs e) HttpApplication app = sender as HttpApplication; app.context.response.write("...ending"); } Rev. 2.2 Copyright 2006 Object Innovations Enterprises, LLC 457

120 AspCs Chapter 13 Using DemoModule This custom module can be used with any application simply by copying DemoModule.dll into the bin folder of the application and providing a <httpmodules> section of Web.config. As a simple example, consider the Greeting application in the chapter directory. <!-- Greeting.aspx --> <HTML> <BODY> Greetings from ASP.NET<br> </BODY> </HTML> The Web.config file is as shown earlier, and the folder Greeting must be configured in IIS as an application. It could also be run using the ASP.NET Development server. Here is the output. Rev. 2.2 Copyright 2006 Object Innovations Enterprises, LLC 458

121 AspCs Chapter 13 Lab 13 Custom Handler and Module for Math Operations In this lab you will create a custom handler for performing simple math operations. In this example, your handler will actually read the target page for input showing the math problems. The output will show the answers. You will also deploy a custom module that displays messages at the beginning of the request (pre-processing) and at the end of the request (post-processing). Detailed instructions are contained in the Lab 13 write-up at the end of the chapter. Suggested time: 60 minutes Rev. 2.2 Copyright 2006 Object Innovations Enterprises, LLC 459

Audience: Experienced application developers or architects responsible for Web applications in a Microsoft environment.

Audience: Experienced application developers or architects responsible for Web applications in a Microsoft environment. ASP.NET Using C# (VS 2010) This five-day course provides a comprehensive and practical hands-on introduction to developing Web applications using ASP.NET 4.0 and C#. It includes an introduction to ASP.NET

More information

ASP.NET Using C# (VS2013)

ASP.NET Using C# (VS2013) ASP.NET Using C# (VS2013) This five-day course provides a comprehensive and practical hands-on introduction to developing Web applications using ASP.NET 4.5.1 and Visual Studio 2013. It includes an introduction

More information

EVALUATION COPY. ASP.NET Using C# Student Guide Revision 4.7. Unauthorized Reproduction or Distribution Prohibited. Object Innovations Course 4140

EVALUATION COPY. ASP.NET Using C# Student Guide Revision 4.7. Unauthorized Reproduction or Distribution Prohibited. Object Innovations Course 4140 ASP.NET Using C# Student Guide Revision 4.7 Object Innovations Course 4140 ASP.NET Using C# Rev. 4.7 Student Guide Information in this document is subject to change without notice. Companies, names and

More information

ASP.NET Using C# Student Guide Revision 4.0. Object Innovations Course 4140

ASP.NET Using C# Student Guide Revision 4.0. Object Innovations Course 4140 ASP.NET Using C# Student Guide Revision 4.0 Object Innovations Course 4140 ASP.NET Using C# Rev. 4.0 Student Guide Information in this document is subject to change without notice. Companies, names and

More information

ASP.NET Using Visual Basic

ASP.NET Using Visual Basic ASP.NET Using Visual Basic Student Guide Revision 4.0 Object Innovations Course 4240 ASP.NET Using Visual Basic Rev. 4.0 Student Guide Information in this document is subject to change without notice.

More information

ASP.NET Using C# (VS2017)

ASP.NET Using C# (VS2017) ASP.NET Using C# (VS 2017) This five-day course provides a comprehensive and practical hands-on introduction to developing Web applications using ASP.NET and Visual Studio 2017. It includes an introduction

More information

Beginning ASP.NET. 4.5 in C# Matthew MacDonald

Beginning ASP.NET. 4.5 in C# Matthew MacDonald Beginning ASP.NET 4.5 in C# Matthew MacDonald Contents About the Author About the Technical Reviewers Acknowledgments Introduction xxvii xxix xxxi xxxiii UPart 1: Introducing.NET. 1 & Chapter 1: The Big

More information

"Charting the Course... MOC A Introduction to Web Development with Microsoft Visual Studio Course Summary

Charting the Course... MOC A Introduction to Web Development with Microsoft Visual Studio Course Summary Description Course Summary This course provides knowledge and skills on developing Web applications by using Microsoft Visual. Objectives At the end of this course, students will be Explore ASP.NET Web

More information

ASP.NET 2.0 p. 1.NET Framework 2.0 p. 2 ASP.NET 2.0 p. 4 New Features p. 5 Special Folders Make Integration Easier p. 5 Security p.

ASP.NET 2.0 p. 1.NET Framework 2.0 p. 2 ASP.NET 2.0 p. 4 New Features p. 5 Special Folders Make Integration Easier p. 5 Security p. Preface p. xix ASP.NET 2.0 p. 1.NET Framework 2.0 p. 2 ASP.NET 2.0 p. 4 New Features p. 5 Special Folders Make Integration Easier p. 5 Security p. 6 Personalization p. 6 Master Pages p. 6 Navigation p.

More information

DOT NET Syllabus (6 Months)

DOT NET Syllabus (6 Months) DOT NET Syllabus (6 Months) THE COMMON LANGUAGE RUNTIME (C.L.R.) CLR Architecture and Services The.Net Intermediate Language (IL) Just- In- Time Compilation and CLS Disassembling.Net Application to IL

More information

2310C VB - Developing Web Applications Using Microsoft Visual Studio 2008 Course Number: 2310C Course Length: 5 Days

2310C VB - Developing Web Applications Using Microsoft Visual Studio 2008 Course Number: 2310C Course Length: 5 Days 2310C VB - Developing Web Applications Using Microsoft Visual Studio 2008 Course Number: 2310C Course Length: 5 Days Certification Exam This course will help you prepare for the following Microsoft Certified

More information

.NET, C#, and ASP.NET p. 1 What Is.NET? p. 2 The Common Language Runtime p. 2 Introducing C# p. 3 Introducing ASP.NET p. 4 Getting Started p.

.NET, C#, and ASP.NET p. 1 What Is.NET? p. 2 The Common Language Runtime p. 2 Introducing C# p. 3 Introducing ASP.NET p. 4 Getting Started p. Introduction p. xix.net, C#, and ASP.NET p. 1 What Is.NET? p. 2 The Common Language Runtime p. 2 Introducing C# p. 3 Introducing ASP.NET p. 4 Getting Started p. 5 Installing Internet Information Server

More information

ASP.NET Web Forms Programming Using Visual Basic.NET

ASP.NET Web Forms Programming Using Visual Basic.NET ASP.NET Web Forms Programming Using Visual Basic.NET Duration: 35 hours Price: $750 Delivery Option: Attend training via an on-demand, self-paced platform paired with personal instructor facilitation.

More information

The Processing Directives of a Page p. 91 The Page Class p. 99 Properties of the Page Class p. 100 Methods of the Page Class p.

The Processing Directives of a Page p. 91 The Page Class p. 99 Properties of the Page Class p. 100 Methods of the Page Class p. Acknowledgments p. xv Introduction p. xvii Building an ASP.NET Page The ASP.NET Programming Model p. 3 What's ASP.NET, Anyway? p. 4 Programming in the Age of Web Forms p. 5 Event-Driven Programming over

More information

Course ID: 2310C Course Name: Developing Web Applications Using Microsoft Visual Studio 2008

Course ID: 2310C Course Name: Developing Web Applications Using Microsoft Visual Studio 2008 Course ID: 2310C Course Name: Developing Web Applications Using Microsoft Visual Studio 2008 Audience This course is intended for introductory-level Web developers who have knowledge of Hypertext Markup

More information

INTRODUCTION TO.NET. Domain of.net D.N.A. Architecture One Tier Two Tier Three Tier N-Tier THE COMMON LANGUAGE RUNTIME (C.L.R.)

INTRODUCTION TO.NET. Domain of.net D.N.A. Architecture One Tier Two Tier Three Tier N-Tier THE COMMON LANGUAGE RUNTIME (C.L.R.) INTRODUCTION TO.NET Domain of.net D.N.A. Architecture One Tier Two Tier Three Tier N-Tier THE COMMON LANGUAGE RUNTIME (C.L.R.) CLR Architecture and Services The.Net Intermediate Language (IL) Just- In-

More information

Introduction to Web Development with Microsoft Visual Studio 2010

Introduction to Web Development with Microsoft Visual Studio 2010 Introduction to Web Development with Microsoft Visual Studio 2010 Course 10267; 5 Days, Instructor-led Course Description This five-day instructor-led course provides knowledge and skills on developing

More information

DOT NET SYLLABUS FOR 6 MONTHS

DOT NET SYLLABUS FOR 6 MONTHS DOT NET SYLLABUS FOR 6 MONTHS INTRODUCTION TO.NET Domain of.net D.N.A. Architecture One Tier Two Tier Three Tier N-Tier THE COMMON LANGUAGE RUNTIME (C.L.R.) CLR Architecture and Services The.Net Intermediate

More information

.NET-6Weeks Project Based Training

.NET-6Weeks Project Based Training .NET-6Weeks Project Based Training Core Topics 1. C# 2. MS.Net 3. ASP.NET 4. 1 Project MS.NET MS.NET Framework The.NET Framework - an Overview Architecture of.net Framework Types of Applications which

More information

10267 Introduction to Web Development with Microsoft Visual Studio 2010

10267 Introduction to Web Development with Microsoft Visual Studio 2010 10267 Introduction to Web Development with Microsoft Visual Studio 2010 Course Number: 10267A Category: Visual Studio 2010 Duration: 5 days Course Description This five-day instructor-led course provides

More information

Introduction to Web Development with Microsoft Visual Studio 2010

Introduction to Web Development with Microsoft Visual Studio 2010 10267 - Introduction to Web Development with Microsoft Visual Studio 2010 Duration: 5 days Course Price: $2,975 Software Assurance Eligible Course Description Course Overview This five-day instructor-led

More information

Assembling a Three-Tier Web Form Application

Assembling a Three-Tier Web Form Application Chapter 16 Objectives Assembling a Three-Tier Application In this chapter, you will: Understand the concept of state for Web applications Create an ASP.NET user control Use data binding technology Develop

More information

Chapter 9. Web Applications The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill

Chapter 9. Web Applications The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill Chapter 9 Web Applications McGraw-Hill 2010 The McGraw-Hill Companies, Inc. All rights reserved. Chapter Objectives - 1 Explain the functions of the server and the client in Web programming Create a Web

More information

ALPHAPRIMETECH 112 New South Road, Hicksville, NY 11801

ALPHAPRIMETECH 112 New South Road, Hicksville, NY 11801 ALPHAPRIMETECH 112 New South Road, Hicksville, NY 11801 Course Curriculum COMPUTER SYSTEM ANALYST-.NET C# Introduction to.net Framework.NET Framework OverView CLR,CLS MSIL Assemblies NameSpaces.NET Languages

More information

COURSE OUTLINE: OD10267A Introduction to Web Development with Microsoft Visual Studio 2010

COURSE OUTLINE: OD10267A Introduction to Web Development with Microsoft Visual Studio 2010 Course Name OD10267A Introduction to Web Development with Microsoft Visual Studio 2010 Course Duration 2 Days Course Structure Online Course Overview This course provides knowledge and skills on developing

More information

.NET FRAMEWORK. Visual C#.Net

.NET FRAMEWORK. Visual C#.Net .NET FRAMEWORK Intro to.net Platform for the.net Drawbacks of Current Trend Advantages/Disadvantages of Before.Net Features of.net.net Framework Net Framework BCL & CLR, CTS, MSIL, & Other Tools Security

More information

What You Need to Use this Book

What You Need to Use this Book What You Need to Use this Book The following is the list of recommended system requirements for running the code in this book: Windows 2000 Professional or Windows XP Professional with IIS installed Visual

More information

M Developing Microsoft ASP.NET Web Applications Using Visual Studio.NET 5 Day Course

M Developing Microsoft ASP.NET Web Applications Using Visual Studio.NET 5 Day Course Module 1: Overview of the Microsoft.NET Framework This module introduces the conceptual framework of the.net Framework and ASP.NET. Introduction to the.net Framework Overview of ASP.NET Overview of the

More information

SECURED PROGRAMMING IN.NET DETAILED TRAINING CONTENT INDUSTRIAL TRAINING PROGRAM ( )

SECURED PROGRAMMING IN.NET DETAILED TRAINING CONTENT INDUSTRIAL TRAINING PROGRAM ( ) SECURED PROGRAMMING IN.NET DETAILED TRAINING CONTENT INDUSTRIAL TRAINING PROGRAM (2013-2014) MODULE: C# PROGRAMMING CHAPTER 1: INTRODUCING.NET AND C# 1.1 INTRODUCTION TO LANGUAGES C++ C# DIFFERENCES BETWEEN

More information

Mastering VB.NET using Visual Studio 2010 Course Length: 5 days Price: $2,500

Mastering VB.NET using Visual Studio 2010 Course Length: 5 days Price: $2,500 Mastering VB.NET using Visual Studio 2010 Course Length: 5 days Price: $2,500 Summary Each day there will be a combination of presentations, code walk-throughs, and handson projects. The final project

More information

Developing Web Applications Using Microsoft Visual Studio 2008 SP1

Developing Web Applications Using Microsoft Visual Studio 2008 SP1 Developing Web s Using Microsoft Visual Studio 2008 SP1 Introduction This five day instructor led course provides knowledge and skills on developing Web applications by using Microsoft Visual Studio 2008

More information

Developing Web Applications Using Microsoft Visual Studio 2008

Developing Web Applications Using Microsoft Visual Studio 2008 Course 2310C: Developing Web Applications Using Microsoft Visual Studio 2008 Length: 5 Day(s) Published: April 24, 2008 Language(s): English Audience(s): Developers Level: 100 Technology: Microsoft Visual

More information

DE Introduction to Web Development with Microsoft Visual Studio 2010

DE Introduction to Web Development with Microsoft Visual Studio 2010 DE-10267 Introduction to Web Development with Microsoft Visual Studio 2010 Summary Duration 5 Days Audience Developers Level 100 Technology Microsoft Visual Studio 2010 Delivery Method Instructor-led (Classroom)

More information

User Manual. Admin Report Kit for IIS 7 (ARKIIS)

User Manual. Admin Report Kit for IIS 7 (ARKIIS) User Manual Admin Report Kit for IIS 7 (ARKIIS) Table of Contents 1 Admin Report Kit for IIS 7... 1 1.1 About ARKIIS... 1 1.2 Who can Use ARKIIS?... 1 1.3 System requirements... 2 1.4 Technical Support...

More information

10267A CS: Developing Web Applications Using Microsoft Visual Studio 2010

10267A CS: Developing Web Applications Using Microsoft Visual Studio 2010 10267A CS: Developing Web Applications Using Microsoft Visual Studio 2010 Course Overview This instructor-led course provides knowledge and skills on developing Web applications by using Microsoft Visual

More information

Web Forms ASP.NET. 2/12/2018 EC512 - Prof. Skinner 1

Web Forms ASP.NET. 2/12/2018 EC512 - Prof. Skinner 1 Web Forms ASP.NET 2/12/2018 EC512 - Prof. Skinner 1 Active Server Pages (.asp) Used before ASP.NET and may still be in use. Merges the HTML with scripting on the server. Easier than CGI. Performance is

More information

Microsoft Official Courseware Course Introduction to Web Development with Microsoft Visual Studio

Microsoft Official Courseware Course Introduction to Web Development with Microsoft Visual Studio Course Overview: This five-day instructor-led course provides knowledge and skills on developing Web applications by using Microsoft Visual Studio 2010. Prerequisites Before attending this course, students

More information

IN PRACTICE. Daniele Bochicchio Stefano Mostarda Marco De Sanctis. Includes 106 practical techniques MANNING

IN PRACTICE. Daniele Bochicchio Stefano Mostarda Marco De Sanctis. Includes 106 practical techniques MANNING IN PRACTICE Daniele Bochicchio Stefano Mostarda Marco De Sanctis Includes 106 practical techniques MANNING contents preface xv acknowledgments xvii about this book xix about the authors xxiii about the

More information

CHAPTER 1: GETTING STARTED WITH ASP.NET 4 1

CHAPTER 1: GETTING STARTED WITH ASP.NET 4 1 FOREWORD INTRODUCTION xxv xxvii CHAPTER 1: GETTING STARTED WITH ASP.NET 4 1 Microsoft Visual Web Developer 2 Getting Visual Web Developer 3 Installing Visual Web Developer Express 3 Creating Your First

More information

.Net. Course Content ASP.NET

.Net. Course Content ASP.NET .Net Course Content ASP.NET INTRO TO WEB TECHNOLOGIES HTML ü Client side scripting langs ü lls Architecture ASP.NET INTRODUCTION ü What is ASP.NET ü Image Technique and code behind technique SERVER SIDE

More information

Getting Started with the Bullhorn SOAP API and C#/.NET

Getting Started with the Bullhorn SOAP API and C#/.NET Getting Started with the Bullhorn SOAP API and C#/.NET Introduction This tutorial is for developers who develop custom applications that use the Bullhorn SOAP API and C#. You develop a sample application

More information

Microsoft ASP.NET Using Visual Basic 2008: Volume 1 Table of Contents

Microsoft ASP.NET Using Visual Basic 2008: Volume 1 Table of Contents Table of Contents INTRODUCTION...INTRO-1 Prerequisites...INTRO-2 Installing the Practice Files...INTRO-3 Software Requirements...INTRO-3 Installation...INTRO-3 The Chapter Files...INTRO-3 Sample Database...INTRO-3

More information

"Charting the Course... MOC A Developing Data Access Solutions with Microsoft Visual Studio Course Summary

Charting the Course... MOC A Developing Data Access Solutions with Microsoft Visual Studio Course Summary Description Course Summary In this course, experienced developers who know the basics of data access (CRUD) in Windows client and Web application environments will learn to optimize their designs and develop

More information

ASP.NET Training Course Duration. 30 Working days, daily one and half hours. ASP.NET Training Course Overview

ASP.NET Training Course Duration. 30 Working days, daily one and half hours. ASP.NET Training Course Overview ASP.NET Training Course Duration 30 Working days, daily one and half hours ASP.NET Training Course Overview Introduction To Web Applications [Prerequisites] Types of Applications Web, Desktop & Mobile

More information

Migrate Your Skills to Microsoft.NET Framework 2.0 and 3.0 using Visual Studio 2005 (C#)

Migrate Your Skills to Microsoft.NET Framework 2.0 and 3.0 using Visual Studio 2005 (C#) Migrate Your Skills to Microsoft.NET Framework 2.0 and 3.0 using Visual Studio 2005 (C#) Course Length: 5 Days Course Overview This instructor-led course teaches developers to gain in-depth guidance on

More information

SERVICE-ORIENTED COMPUTING

SERVICE-ORIENTED COMPUTING THIRD EDITION (REVISED PRINTING) SERVICE-ORIENTED COMPUTING AND WEB SOFTWARE INTEGRATION FROM PRINCIPLES TO DEVELOPMENT YINONG CHEN AND WEI-TEK TSAI ii Table of Contents Preface (This Edition)...xii Preface

More information

DE-2310 Developing Web Applications Using Microsoft Visual Studio 2008 SP1

DE-2310 Developing Web Applications Using Microsoft Visual Studio 2008 SP1 DE-2310 Developing Web Applications Using Microsoft Visual Studio 2008 SP1 Summary Duration 5 Days Audience Developers Level 100 Technology Microsoft Visual Studio 2008 Delivery Method Instructor-led (Classroom)

More information

Apex TG India Pvt. Ltd.

Apex TG India Pvt. Ltd. (Core C# Programming Constructs) Introduction of.net Framework 4.5 FEATURES OF DOTNET 4.5 CLR,CLS,CTS, MSIL COMPILER WITH TYPES ASSEMBLY WITH TYPES Basic Concepts DECISION CONSTRUCTS LOOPING SWITCH OPERATOR

More information

ASP.NET - MANAGING STATE

ASP.NET - MANAGING STATE ASP.NET - MANAGING STATE http://www.tutorialspoint.com/asp.net/asp.net_managing_state.htm Copyright tutorialspoint.com Hyper Text Transfer Protocol HTTP is a stateless protocol. When the client disconnects

More information

Developing Microsoft.NET Applications for Windows (Visual Basic.NET)

Developing Microsoft.NET Applications for Windows (Visual Basic.NET) Developing Microsoft.NET Applications for Windows (Visual Basic.NET) Course Number: 2565 Length: 5 Day(s) Certification Exam This course will help you prepare for the following Microsoft Certified Professional

More information

DEVELOPING WEB APPLICATIONS WITH MICROSOFT VISUAL STUDIO Course: 10264A; Duration: 5 Days; Instructor-led

DEVELOPING WEB APPLICATIONS WITH MICROSOFT VISUAL STUDIO Course: 10264A; Duration: 5 Days; Instructor-led CENTER OF KNOWLEDGE, PATH TO SUCCESS Website: DEVELOPING WEB APPLICATIONS WITH MICROSOFT VISUAL STUDIO 2010 Course: 10264A; Duration: 5 Days; Instructor-led WHAT YOU WILL LEARN In this course, students

More information

.Net Interview Questions

.Net Interview Questions .Net Interview Questions 1.What is.net? NET is an integral part of many applications running on Windows and provides common functionality for those applications to run. This download is for people who

More information

Hands On, Instructor-Led IT Courses Across Colorado

Hands On, Instructor-Led IT Courses Across Colorado Hands On, Instructor-Led IT Courses Across Colorado Offering instructor-led courses in: Java, Java EE and OOAD SQL Programming and SQL Server UNIX, Linux Administration.NET Programming Web Programming

More information

Getting Started with EPiServer 4

Getting Started with EPiServer 4 Getting Started with EPiServer 4 Abstract This white paper includes information on how to get started developing EPiServer 4. The document includes, among other things, high-level installation instructions,

More information

10264A CS: Developing Web Applications with Microsoft Visual Studio 2010

10264A CS: Developing Web Applications with Microsoft Visual Studio 2010 10264A CS: Developing Web Applications with Microsoft Visual Studio 2010 Course Number: 10264A Course Length: 5 Days Course Overview In this course, students will learn to develop advanced ASP.NET MVC

More information

Microsoft.NET Programming (C#, ASP.NET,ADO.NET, VB.NET, Crystal Report, Sql Server) Goal: Make the learner proficient in the usage of MS Technologies

Microsoft.NET Programming (C#, ASP.NET,ADO.NET, VB.NET, Crystal Report, Sql Server) Goal: Make the learner proficient in the usage of MS Technologies Microsoft.NET Programming (C#, ASP.NET,ADO.NET, VB.NET, Crystal Report, Sql Server) Goal: Make the learner proficient in the usage of MS Technologies for web applications development using ASP.NET, XML,

More information

Course Outline: Course 10267A: Introduction to Web Development with Microsoft Visual Studio 2010 Learning Method: Instructor-led Classroom Learning

Course Outline: Course 10267A: Introduction to Web Development with Microsoft Visual Studio 2010 Learning Method: Instructor-led Classroom Learning Course Outline: Course 10267A: Introduction to Web Development with Microsoft Visual Studio 2010 Learning Method: Instructor-led Classroom Learning Duration: 5.00 Day(s)/ 40 hrs Overview: This five-day

More information

Pro ASP.NET MVC 2 Framework

Pro ASP.NET MVC 2 Framework Pro ASP.NET MVC 2 Framework Second Edition Steven Sanderson Apress TIB/UB Hannover 89 133 297 713 Contents at a Glance Contents About the Author About the Technical Reviewers Acknowledgments Introduction

More information

Saikat Banerjee Page 1

Saikat Banerjee Page 1 1.What is.net? NET is an integral part of many applications running on Windows and provides common functionality for those applications to run. This download is for people who need.net to run an application

More information

[MS20487]: Developing Windows Azure and Web Services

[MS20487]: Developing Windows Azure and Web Services [MS20487]: Developing Windows Azure and Web Services Length : 5 Days Audience(s) : Developers Level : 300 Technology : Cross-Platform Development Delivery Method : Instructor-led (Classroom) Course Overview

More information

Pro Business Applications with Silverlight 4

Pro Business Applications with Silverlight 4 Pro Business Applications with Silverlight 4 Chris Anderson Apress* Contents at a Glance Contents About the Author Acknowledgments iv v xix xx a Chapter 1: Introduction 1 Who This Book Is For 1 About This

More information

20486: Developing ASP.NET MVC 4 Web Applications (5 Days)

20486: Developing ASP.NET MVC 4 Web Applications (5 Days) www.peaklearningllc.com 20486: Developing ASP.NET MVC 4 Web Applications (5 Days) About this Course In this course, students will learn to develop advanced ASP.NET MVC applications using.net Framework

More information

Web Platform Introduction With a focus on free. Mike Taulty Developer & Platform Group Microsoft Ltd

Web Platform Introduction With a focus on free. Mike Taulty Developer & Platform Group Microsoft Ltd Web Platform Introduction With a focus on free Mike Taulty Developer & Platform Group Microsoft Ltd Mike.Taulty@microsoft.com http://www.mtaulty.com The humble web request Internet Information Services

More information

Active Server Pages Architecture

Active Server Pages Architecture Active Server Pages Architecture Li Yi South Bank University Contents 1. Introduction... 2 1.1 Host-based databases... 2 1.2 Client/server databases... 2 1.3 Web databases... 3 2. Active Server Pages...

More information

Developing ASP.NET MVC 4 Web Applications

Developing ASP.NET MVC 4 Web Applications Developing ASP.NET MVC 4 Web Applications Course 20486B; 5 days, Instructor-led Course Description In this course, students will learn to develop advanced ASP.NET MVC applications using.net Framework 4.5

More information

Getting Started with EPiServer 4

Getting Started with EPiServer 4 Getting Started with EPiServer 4 Abstract This white paper includes information on how to get started developing EPiServer 4. The document includes, among other things, high-level installation instructions,

More information

COURSE 20487B: DEVELOPING WINDOWS AZURE AND WEB SERVICES

COURSE 20487B: DEVELOPING WINDOWS AZURE AND WEB SERVICES ABOUT THIS COURSE In this course, students will learn how to design and develop services that access local and remote data from various data sources. Students will also learn how to develop and deploy

More information

DOT NET COURSE BROCHURE

DOT NET COURSE BROCHURE Page 1 1Pointer Technology Chacko Towers,Anna nagar Main Road, Anna Nager(Annai Insititute 2nd Floor) Pondicherry-05 Mobile :+91-9600444787,9487662326 Website : http://www.1pointer.com/ Email : info@1pointer.com/onepointertechnology@gmail.com

More information

"Charting the Course... SharePoint 2007 Hands-On Labs Course Summary

Charting the Course... SharePoint 2007 Hands-On Labs Course Summary Course Summary Description This series of 33 hands-on labs allows students to explore the new features of Microsoft SharePoint Server, Microsoft Windows, Microsoft Office, including Microsoft Office Groove,

More information

Migrate From Version 2.2 to Version 3.1 Guide

Migrate From Version 2.2 to Version 3.1 Guide Migrate From Version 2.2 to Version 3.1 Guide EFM Community Fall 2007(Version 3.10) July 2008 For support, contact Vovici Technical Support at (781) 261-4300, ext. 2 or use the web form located at: http://s3.parature.com/ics/support/default.asp?deptid=5474

More information

COURSE 20486B: DEVELOPING ASP.NET MVC 4 WEB APPLICATIONS

COURSE 20486B: DEVELOPING ASP.NET MVC 4 WEB APPLICATIONS ABOUT THIS COURSE In this course, students will learn to develop advanced ASP.NET MVC applications using.net Framework 4.5 tools and technologies. The focus will be on coding activities that enhance the

More information

Unit-3 State Management in ASP.NET

Unit-3 State Management in ASP.NET STATE MANAGEMENT Web is Stateless. It means a new instance of the web page class is re-created each time the page is posted to the server. As we all know HTTP is a stateless protocol, it s can't holds

More information

Web-based Apps in.net

Web-based Apps in.net Web-based Apps in.net Objectives Real-world applications are typically multi-tier, distributed designs involving many components the web server being perhaps the most important component in today's applications...

More information

Building Web Sites Using the EPiServer Content Framework

Building Web Sites Using the EPiServer Content Framework Building Web Sites Using the EPiServer Content Framework Product version: 4.60 Document version: 1.0 Document creation date: 28-03-2006 Purpose A major part in the creation of a Web site using EPiServer

More information

Developing Windows Azure and Web Services

Developing Windows Azure and Web Services Developing Windows Azure and Web Services Course 20487B; 5 days, Instructor-led Course Description In this course, students will learn how to design and develop services that access local and remote data

More information

978.256.9077 admissions@brightstarinstitute.com Microsoft.NET Developer: VB.NET Certificate Online, self-paced training that is focused on giving you the skills needed to stand out. Online learning gives

More information

Advanced WCF 4.0 .NET. Web Services. Contents for.net Professionals. Learn new and stay updated. Design Patterns, OOPS Principles, WCF, WPF, MVC &LINQ

Advanced WCF 4.0 .NET. Web Services. Contents for.net Professionals. Learn new and stay updated. Design Patterns, OOPS Principles, WCF, WPF, MVC &LINQ Serialization PLINQ WPF LINQ SOA Design Patterns Web Services 4.0.NET Reflection Reflection WCF MVC Microsoft Visual Studio 2010 Advanced Contents for.net Professionals Learn new and stay updated Design

More information

CST272 Getting Started Page 1

CST272 Getting Started Page 1 CST272 Getting Started Page 1 1 2 3 4 5 6 8 Introduction to ASP.NET, Visual Studio and C# CST272 ASP.NET Static and Dynamic Web Applications Static Web pages Created with HTML controls renders exactly

More information

Migrate From Version 3.1 to Version 4 Guide Vovici Enterprise 4.0. December 2008

Migrate From Version 3.1 to Version 4 Guide Vovici Enterprise 4.0. December 2008 Migrate From Version 3.1 to Version 4 Guide Vovici Enterprise 4.0 December 2008 For installation support, please contact our Vovici installation experts at installefmc@vovici.com. If phone support is requested

More information

CS708 Lecture Notes. Visual Basic.NET Programming. Object-Oriented Programming Web Technologies and ASP.NET. (Part I) (Lecture Notes 5B)

CS708 Lecture Notes. Visual Basic.NET Programming. Object-Oriented Programming Web Technologies and ASP.NET. (Part I) (Lecture Notes 5B) CS708 Lecture Notes Visual Basic.NET Programming Object-Oriented Programming Web Technologies and ASP.NET (Part I) (Lecture Notes 5B) Prof. Abel Angel Rodriguez SECTION I. INTRODUCTION TO WEB APPLICATIONS

More information

Roxen Content Provider

Roxen Content Provider Roxen Content Provider Generation 3 Templates Purpose This workbook is designed to provide a training and reference tool for placing University of Alaska information on the World Wide Web (WWW) using the

More information

Scenario Manager User Guide. Release September 2013

Scenario Manager User Guide. Release September 2013 Scenario Manager User Guide Release 6.2.1 September 2013 Scenario Manager User Guide Release 6.2.1 September 2013 Document Control Number: 9MN12-62110017 Document Number: SMUG-13-FCCM-0017-6.2.1-01 Oracle

More information

JAVA COURSES. Empowering Innovation. DN InfoTech Pvt. Ltd. H-151, Sector 63, Noida, UP

JAVA COURSES. Empowering Innovation. DN InfoTech Pvt. Ltd. H-151, Sector 63, Noida, UP 2013 Empowering Innovation DN InfoTech Pvt. Ltd. H-151, Sector 63, Noida, UP contact@dninfotech.com www.dninfotech.com 1 JAVA 500: Core JAVA Java Programming Overview Applications Compiler Class Libraries

More information

ASP.net. Microsoft. Getting Started with. protected void Page_Load(object sender, EventArgs e) { productsdatatable = new DataTable();

ASP.net. Microsoft. Getting Started with. protected void Page_Load(object sender, EventArgs e) { productsdatatable = new DataTable(); Getting Started with protected void Page_Load(object sender, EventArgs e) { productsdatatable = new DataTable(); string connectionstring = System.Configuration.ConfigurationManager.ConnectionStrings ["default"].connectionstring;!

More information

ASP.NET MVC Training

ASP.NET MVC Training TRELLISSOFT ASP.NET MVC Training About This Course: Audience(s): Developers Technology: Visual Studio Duration: 6 days (48 Hours) Language(s): English Overview In this course, students will learn to develop

More information

Introduction to.net Framework Week 1. Tahir Nawaz

Introduction to.net Framework Week 1. Tahir Nawaz Introduction to.net Framework Week 1 Tahir Nawaz .NET What Is It? Software platform Language neutral In other words:.net is not a language (Runtime and a library for writing and executing written programs

More information

Developing Microsoft.NET Applications for Windows (Visual C#.NET)

Developing Microsoft.NET Applications for Windows (Visual C#.NET) Developing Microsoft.NET Applications for Windows (Visual C#.NET) Key Data Course #: 2555 Number of Days: 5 Format: Instructor-Led Certification Exams: TBD This course helps you prepare for the following

More information

Dot Net Online Training

Dot Net Online Training chakraitsolutions.com http://chakraitsolutions.com/dotnet-online-training/ Dot Net Online Training DOT NET Online Training CHAKRA IT SOLUTIONS TO LEARN ABOUT OUR UNIQUE TRAINING PROCESS: Title : Dot Net

More information

Course 20486B: Developing ASP.NET MVC 4 Web Applications

Course 20486B: Developing ASP.NET MVC 4 Web Applications Course 20486B: Developing ASP.NET MVC 4 Web Applications Overview In this course, students will learn to develop advanced ASP.NET MVC applications using.net Framework 4.5 tools and technologies. The focus

More information

20486-Developing ASP.NET MVC 4 Web Applications

20486-Developing ASP.NET MVC 4 Web Applications Course Outline 20486-Developing ASP.NET MVC 4 Web Applications Duration: 5 days (30 hours) Target Audience: This course is intended for professional web developers who use Microsoft Visual Studio in an

More information

Lab 5: ASP.NET 2.0 Profiles and Localization

Lab 5: ASP.NET 2.0 Profiles and Localization Lab 5: ASP.NET 2.0 Profiles and Localization Personalizing content for individual users and persisting per-user data has always been a non-trivial undertaking in Web apps, in part due to the stateless

More information

EMC ApplicationXtender Web Access.NET eroom Integration 6.0

EMC ApplicationXtender Web Access.NET eroom Integration 6.0 EMC ApplicationXtender Web Access.NET eroom Integration 6.0 Administrator s Guide 300-008-282 REV A01 EMC Corporation Corporate Headquarters: Hopkinton, MA 01748-9103 1-508-435-1000 www.emc.com Copyright

More information

Chapter 3. Windows Database Applications The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill

Chapter 3. Windows Database Applications The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill Chapter 3 Windows Database Applications McGraw-Hill 2010 The McGraw-Hill Companies, Inc. All rights reserved. Objectives - 1 Retrieve and display data from a SQL Server database on Windows forms Use the

More information

Developing ASP.NET MVC 4 Web Applications

Developing ASP.NET MVC 4 Web Applications Developing ASP.NET MVC 4 Web Applications Duration: 5 Days Course Code: 20486B About this course In this course, students will learn to develop advanced ASP.NET MVC applications using.net Framework 4.5

More information

Web Development with ASP.Net

Web Development with ASP.Net Western Technical College 10152187 Web Development with ASP.Net Course Outcome Summary Course Information Description Career Cluster Instructional Level Total Credits 3.00 Total Hours 72.00 This programming

More information

COPYRIGHTED MATERIAL. Introducing the Project: The SmartCA Application. The Problem

COPYRIGHTED MATERIAL. Introducing the Project: The SmartCA Application. The Problem Introducing the Project: The SmartCA Application The project for this book is based on a real application for a real company. The names of the company and the application have been changed for privacy

More information

MS-20487: Developing Windows Azure and Web Services

MS-20487: Developing Windows Azure and Web Services MS-20487: Developing Windows Azure and Web Services Description In this course, students will learn how to design and develop services that access local and remote data from various data sources. Students

More information

Visual Studio Course Developing ASP.NET MVC 5 Web Applications

Visual Studio Course Developing ASP.NET MVC 5 Web Applications Visual Studio Course - 20486 Developing ASP.NET MVC 5 Web Applications Length 5 days Prerequisites Before attending this course, students must have: In this course, students will learn to develop advanced

More information

5.1 Configuring Authentication, Authorization, and Impersonation. 5.2 Configuring Projects, Solutions, and Reference Assemblies

5.1 Configuring Authentication, Authorization, and Impersonation. 5.2 Configuring Projects, Solutions, and Reference Assemblies LESSON 5 5.1 Configuring Authentication, Authorization, and Impersonation 5.2 Configuring Projects, Solutions, and Reference Assemblies 5.3 Publish Web Applications 5.4 Understand Application Pools MTA

More information

1.1 Customize the Layout and Appearance of a Web Page. 1.2 Understand ASP.NET Intrinsic Objects. 1.3 Understand State Information in Web Applications

1.1 Customize the Layout and Appearance of a Web Page. 1.2 Understand ASP.NET Intrinsic Objects. 1.3 Understand State Information in Web Applications LESSON 1 1.1 Customize the Layout and Appearance of a Web Page 1.2 Understand ASP.NET Intrinsic Objects 1.3 Understand State Information in Web Applications 1.4 Understand Events and Control Page Flow

More information