Transcript
Page 1: Introducing ASP.NET 2.0. Internet Technologies WWW Architecture Web Server Client Server Request Response Network HTTP TCP/IP PC/Mac/Unix + Browser (IE,

Introducing ASP.NET 2.0

Page 2: Introducing ASP.NET 2.0. Internet Technologies WWW Architecture Web Server Client Server Request Response Network HTTP TCP/IP PC/Mac/Unix + Browser (IE,

Internet TechnologiesWWW Architecture

Web Server

Client

Server

Request

Response

Network HTTPTCP/IP

PC/Mac/Unix + Browser (IE, FireFox)

Page 3: Introducing ASP.NET 2.0. Internet Technologies WWW Architecture Web Server Client Server Request Response Network HTTP TCP/IP PC/Mac/Unix + Browser (IE,

Internet TechnologiesWWW Architecture

Client-side: HTML / XHTML (Extensible HyperText Markup Language) JavaScript / VBScript (client-side scripting) Applets / ActiveX controls

Server-side: PHP JSP (Java Server Pages) ASP (Active Server Pages) ASP.NET (next generation of ASP)

Page 4: Introducing ASP.NET 2.0. Internet Technologies WWW Architecture Web Server Client Server Request Response Network HTTP TCP/IP PC/Mac/Unix + Browser (IE,

Server-Side Code

What is server-side code? Software that runs on the

server, not the client Receives input from

URL parameters HTML form data

Can access server-side databases, e-mail servers, files, mainframes, etc.

Dynamically builds a custom HTML response for a client

HTTP request(form data,

HTTP header data)

HTTP responseHTML, XML

ASP page(static HTML, server-side logic)

Page 5: Introducing ASP.NET 2.0. Internet Technologies WWW Architecture Web Server Client Server Request Response Network HTTP TCP/IP PC/Mac/Unix + Browser (IE,

Static vs Dynamic Web Pages

Most Web pages that you view are not static HTML pages

Instead they are dynamic generated content output from programs that run on servers

These programs can interact with server resources like databases and XML Web services

Page 6: Introducing ASP.NET 2.0. Internet Technologies WWW Architecture Web Server Client Server Request Response Network HTTP TCP/IP PC/Mac/Unix + Browser (IE,

ASP.NET Overview

ASP.NET is a revolutionary programming framework that enables the rapid development of powerful web applications and services

It’s a part of the emerging Microsoft .NET Platform

It provides the easiest and most scalable way to build, deploy and run distributed web applications that can target any browser or device

Page 7: Introducing ASP.NET 2.0. Internet Technologies WWW Architecture Web Server Client Server Request Response Network HTTP TCP/IP PC/Mac/Unix + Browser (IE,

Why ASP .NET?

Make it easier to build web appsMake it easier to deploy web appsMake it easier to operate web appsProvide greater performance, reliability, and

scalability

Page 8: Introducing ASP.NET 2.0. Internet Technologies WWW Architecture Web Server Client Server Request Response Network HTTP TCP/IP PC/Mac/Unix + Browser (IE,

ASP .NET Capabilities

1.It’s really, really fast!2.Deploy and upgrade running apps with

XCOPY3.Great tools support4.Automatically detects and recovers from

errors5.Built-in output caching6.Supports wide range of mobile devices7.Uses compiled languages8.Makes building web services easy9.Much simpler page development model

Page 9: Introducing ASP.NET 2.0. Internet Technologies WWW Architecture Web Server Client Server Request Response Network HTTP TCP/IP PC/Mac/Unix + Browser (IE,

The .NET Framework

.NET Framework is a collection of technologies for the development and deployment of .NET software systems

Common Language Runtime (CLR) Unifies programming models Provides robust and secure execution environment Supports multiple programming languages Provides core services

Memory management (Garbage Collection) Thread management Remoting Manage Code Execution

“Like” Java Runtime Environment (JRE) Code is NOT interpreted by CLR, but managed

Common Language Specification Set of features guaranteed to be in all languages

Page 10: Introducing ASP.NET 2.0. Internet Technologies WWW Architecture Web Server Client Server Request Response Network HTTP TCP/IP PC/Mac/Unix + Browser (IE,

The .NET Framework

Aim of .NET : seamless interoperability A component in any .NET language can:

Inherit from any other .NET language class Call the methods of any other .NET language class

Benefits of .Net Rich UI Toolkit, even for the web (ASP.Net) Language independence (VB.Net, C#, J#, C++, COBOL,

and others) Standard based (XML, SOAP, HTTP) Interoperability with COM .Net Framework Library

Rich set of classes

Page 11: Introducing ASP.NET 2.0. Internet Technologies WWW Architecture Web Server Client Server Request Response Network HTTP TCP/IP PC/Mac/Unix + Browser (IE,

The .NET Framework

Common Language Specification

Common Language Runtime

VB C++ C#

ASP.NET: Web Servicesand Web Forms

JScript …

WindowsForms

.NET Framework Base Classes

ADO.NET: Data and XML

Visu

al Stu

dio

.NE

T

Page 12: Introducing ASP.NET 2.0. Internet Technologies WWW Architecture Web Server Client Server Request Response Network HTTP TCP/IP PC/Mac/Unix + Browser (IE,

Example of ASP.NET

<%@ Page language=“C#"%><HTML>

<Script runat="server">void btnSubmit_OnClick(Object sender, EventArgs e){

lbl1.Text = “Hello World!";}

</Script><body>

<form runat="server"><asp:Label id="lbl1" runat="server" /><br><asp:Button id="btn1" runat="server"

Text="Click" OnClick="btnSubmit_OnClick" /></form>

</body></HTML>

start.aspx ASP.NET Directive Specify used language

Server side script

ASP.NET web formNote one page can have only one web form

ASP.NET web control

Event Handler

Page 13: Introducing ASP.NET 2.0. Internet Technologies WWW Architecture Web Server Client Server Request Response Network HTTP TCP/IP PC/Mac/Unix + Browser (IE,

Example of ASP.NET

Result

ClickClick

Hello World!

Client Web Browser

Page 14: Introducing ASP.NET 2.0. Internet Technologies WWW Architecture Web Server Client Server Request Response Network HTTP TCP/IP PC/Mac/Unix + Browser (IE,

Example of ASP.NET

Result

Click

Hello World!

Client Web Browser <asp:Label id="lbl1" runat="server" /><br>

<asp:Button id="btn1" runat="server“ Text="Click" OnClick="btnSubmit_OnClick" />

void btnSubmit_OnClick(Object sender, EventArgs e){

lbl1.Text = “Hello World!";}

ASP.NET server controlBefore user clicks the button,this control is invisible

ASP.NET server controlAll have Id and Text attributesCreate browser-specific HTML

Event handler functionThis function specifies what to dowhen some event occurs.In these case, it changes “lbl1” control’s text

Page 15: Introducing ASP.NET 2.0. Internet Technologies WWW Architecture Web Server Client Server Request Response Network HTTP TCP/IP PC/Mac/Unix + Browser (IE,

Round trip

start.aspx

Client Browser

lbl1

btn1

Post Data

lbl1=“”submit=btn1

Event occursSend data

Event handler

btnSubmit_OnClick

Server

Event occurs

Example of ASP.NET

Page 16: Introducing ASP.NET 2.0. Internet Technologies WWW Architecture Web Server Client Server Request Response Network HTTP TCP/IP PC/Mac/Unix + Browser (IE,

ASP.NET Web Forms

An ASP.NET web application: Consists of any number of web pages, controls,

programming classes, web services, and other files Residing within a single web server application directory

The principle component of an ASP.NET web application are its web pages

These are text files with an .aspx extension and are called web forms

Consists of two parts: The declaratively-defined (i.e., by markup/ tags) visual

elements The programming logic

Page 17: Introducing ASP.NET 2.0. Internet Technologies WWW Architecture Web Server Client Server Request Response Network HTTP TCP/IP PC/Mac/Unix + Browser (IE,

Web Form Programming Logic

A web form’s programming logic can exist in either: The same file as the visual elements

i.e., the .aspx file This code is contained within a code-declaration block

In a separate class file The file is usually called a code-behind file By conversation, its filename is same as .aspx file but

with a language extension HelloWorld.aspx <- web form HelloWorld.aspx.cs <-code-behind file

Page 18: Introducing ASP.NET 2.0. Internet Technologies WWW Architecture Web Server Client Server Request Response Network HTTP TCP/IP PC/Mac/Unix + Browser (IE,

Why Use Code-Behind?

The real advantage of separating the code into its own file is that it may lead to more maintainable web forms One of the main benefits of ASP.NET is that a page’s

programming logic can be conceptually separated from the presentation

By using a code-behind file a page’s programming logic can also be physically separated from the presentation/markup

Page 19: Introducing ASP.NET 2.0. Internet Technologies WWW Architecture Web Server Client Server Request Response Network HTTP TCP/IP PC/Mac/Unix + Browser (IE,

Why Use Code-Behind?

By placing the programming code into its own file, it is also potentially easier to make use of a division of labor in the creation of the site

Use whichever model you want However, all the examples in text use code-behind

Page 20: Introducing ASP.NET 2.0. Internet Technologies WWW Architecture Web Server Client Server Request Response Network HTTP TCP/IP PC/Mac/Unix + Browser (IE,

Web Application Structure

An ASP.NET web application can simply consist of a folder containing web forms and other files

You can add any number of additional nested subfolders within this root folder

ASP.NET has a number of reserved application folder names, e.g. App_Code App_Data App_Theme


Top Related