© 2004 the University of Greenwich 1 Introduction to the Web and.NET Kevin McManus Adapted from...

84
© 2004 the University of Greenwich 1 Introduction to the Web and .NET Kevin McManus Adapted from material by Mark Sapossnek Computer Science Department Metropolitan College Boston University © 2004 the University of Greenwich 1
  • date post

    20-Jan-2016
  • Category

    Documents

  • view

    219
  • download

    0

Transcript of © 2004 the University of Greenwich 1 Introduction to the Web and.NET Kevin McManus Adapted from...

Page 1: © 2004 the University of Greenwich 1 Introduction to the Web and.NET Kevin McManus Adapted from material by Mark Sapossnek Computer Science Department.

© 2004 the University of Greenwich 1

Introduction to the Weband .NET

Kevin McManus

Adapted from material by Mark SapossnekComputer Science Department

Metropolitan CollegeBoston University

© 2004 the University of Greenwich 1

Page 2: © 2004 the University of Greenwich 1 Introduction to the Web and.NET Kevin McManus Adapted from material by Mark Sapossnek Computer Science Department.

© 2004 the University of Greenwich 2

Agenda

• Internet Technologies

• Programming Languages and Paradigms

• Programming the Web

• .NET Overview

Page 3: © 2004 the University of Greenwich 1 Introduction to the Web and.NET Kevin McManus Adapted from material by Mark Sapossnek Computer Science Department.

© 2004 the University of Greenwich 3

WWW Architecture

Platform: PC, Mac, Unix, etc.Web Server: Apache, IIS, Xitami, etc.

Platform: PC, Mac, Unix, etc.Browser: IE, Mozilla, Opera, etc.Client

Server

Request:http://www.gre.ac.uk/about

Response:<html>…</html>

Network HTTP over TCP/IP

Page 4: © 2004 the University of Greenwich 1 Introduction to the Web and.NET Kevin McManus Adapted from material by Mark Sapossnek Computer Science Department.

© 2004 the University of Greenwich 4

Internet TechnologiesWWW Architecture

• Client/Server, Request/Response architecture• You request a Web page

• e.g. http://www.msn.com/default.asp?name-Leon• HTTP request

• The Web server responds with data in the form of a Web page• HTTP response• Web page is expressed as (X)HTML

• Pages are identified as a Uniform Resource Locator (URL)• Protocol: http• Web server: www• Domain msn.com• Web page: default.asp• GET parameters: ?name=Leon

Page 5: © 2004 the University of Greenwich 1 Introduction to the Web and.NET Kevin McManus Adapted from material by Mark Sapossnek Computer Science Department.

© 2004 the University of Greenwich 5

Internet TechnologiesWeb Standards

• Internet Engineering Task Force (IETF)• http://www.ietf.org/

• Founded 1986

• Request For Comments (RFC) at http://www.ietf.org/rfc.html

• World Wide Web Consortium (W3C)• http://www.w3.org

• Founded 1994 by Tim Berners-Lee

• Publishes technical reports and recommendations

Page 6: © 2004 the University of Greenwich 1 Introduction to the Web and.NET Kevin McManus Adapted from material by Mark Sapossnek Computer Science Department.

© 2004 the University of Greenwich 6

Internet TechnologiesHypertext Markup Language (HTML)

• The markup language used to create web pages for viewing by people• Designed to display data, not store/transfer data

• Rendered and viewed in a Web browser• Can contain links to images, documents,

and other pages• W3C standard• Derived from Standard Generalized Markup Language

(SGML)• HTML 3.2, 4.01, XHTML 1.0

Page 7: © 2004 the University of Greenwich 1 Introduction to the Web and.NET Kevin McManus Adapted from material by Mark Sapossnek Computer Science Department.

© 2004 the University of Greenwich 7

Internet TechnologiesHTML Forms

• Enables you to create interactive user interface elements• Buttons• Text boxes• Lists, menues• Check boxes, radio buttons

• User fills out the form and submits it• Form data is sent to the web server when the

form is submitted• Part of the HTTP request• use either the GET or POST method

Page 8: © 2004 the University of Greenwich 1 Introduction to the Web and.NET Kevin McManus Adapted from material by Mark Sapossnek Computer Science Department.

© 2004 the University of Greenwich 8

Internet TechnologiesHypertext Transport Protocol (HTTP)

• The top-level protocol used to request and return data • e.g. HTML pages, GIFs, JPEGs, Microsoft Word

documents, Adobe PDF documents, etc.

• Request/Response protocol• Methods: GET, POST, HEAD, …• HTTP 1.0: simple • HTTP 1.1: more complex

Page 9: © 2004 the University of Greenwich 1 Introduction to the Web and.NET Kevin McManus Adapted from material by Mark Sapossnek Computer Science Department.

© 2004 the University of Greenwich 9

GET /default.asp HTTP/1.0Accept: image/gif, image/x-bitmap, image/jpeg, */*Accept-Language: enUser-Agent: Mozilla/1.22 (compatible; MSIE 2.0; Windows 95)Connection: Keep-AliveIf-Modified-Since: Sunday, 17-Apr-96 04:32:58 GMT

Internet TechnologiesHTTP Request

Method File HTTP version Headers

Data – none for GET

Blank line

Page 10: © 2004 the University of Greenwich 1 Introduction to the Web and.NET Kevin McManus Adapted from material by Mark Sapossnek Computer Science Department.

© 2004 the University of Greenwich 10

HTTP/1.0 200 OKDate: Sun, 21 Apr 1996 02:20:42 GMTServer: Microsoft-Internet-Information-Server/5.0 Connection: keep-aliveContent-Type: text/htmlLast-Modified: Thu, 18 Apr 1996 17:39:05 GMTContent-Length: 2543 <HTML> Some data... blah, blah, blah </HTML>

Internet TechnologiesHTTP Response

HTTP version Status code Reason phrase Headers

Data

Page 11: © 2004 the University of Greenwich 1 Introduction to the Web and.NET Kevin McManus Adapted from material by Mark Sapossnek Computer Science Department.

© 2004 the University of Greenwich 11

Internet TechnologiesHTTP Server Status Codes

Code Description

200 OK

201 Created

301 Moved Permanently

302 Moved Temporarily

400 Bad Request – not understood

401 Unauthorized

403 Forbidden – not authorized

404 Not Found

500 Internal Server Error

Page 12: © 2004 the University of Greenwich 1 Introduction to the Web and.NET Kevin McManus Adapted from material by Mark Sapossnek Computer Science Department.

© 2004 the University of Greenwich 12

Internet TechnologiesHTTP

• HTTP is a stateless protocol

• Each HTTP request is independent of previous and subsequent requests

• HTTP 1.1 introduced keep-alive for efficiency

• Statelessness has a big impact on how scalable applications are designed

Page 13: © 2004 the University of Greenwich 1 Introduction to the Web and.NET Kevin McManus Adapted from material by Mark Sapossnek Computer Science Department.

© 2004 the University of Greenwich 13

Internet TechnologiesCookies

• A mechanism to store a small amount of information (up to 4KB) on the client

• Cookies are associated with a specific web site• A cookie may be sent from a web server to a web client

in the HTTP response header• Cookies are returned to the web server in all subsequent

HTTP requests• Can last for only for the duration of the session (until

browser is closed) or may persist across sessions• Can expire some time in the future• Can persist indefinitely

Page 14: © 2004 the University of Greenwich 1 Introduction to the Web and.NET Kevin McManus Adapted from material by Mark Sapossnek Computer Science Department.

© 2004 the University of Greenwich 14

Internet TechnologiesHTTPS

• A secure version of HTTP

• Allows client and server to exchange data with confidence that the data was neither modified nor intercepted

• Uses Secure Sockets Layer (SSL)/Transport Layer Security (TLS)

Page 15: © 2004 the University of Greenwich 1 Introduction to the Web and.NET Kevin McManus Adapted from material by Mark Sapossnek Computer Science Department.

© 2004 the University of Greenwich 15

Internet TechnologiesURIs, URLs and URNs

• Uniform Resource Identifier (URI = URL or URN)• Generic term for all textual names/addresses

• Uniform Resource Locator (URL)• The set of URI schemes that have explicit instructions

on how to access the resource over the Internet, e.g. http, ftp, gopher

• Uniform Resource Name (URN) 1) A URI that has an institutional commitment to

availability, etc.2) A particular scheme intended to identify resources

e.g. urn:schemas:httpmail:subject

Page 16: © 2004 the University of Greenwich 1 Introduction to the Web and.NET Kevin McManus Adapted from material by Mark Sapossnek Computer Science Department.

© 2004 the University of Greenwich 16

Internet TechnologiesMultipurpose Internet Mail Extensions (MIME)

• Defines types of data/documents• text/plain• text/html• image/gif• image/jpeg• audio/x-pn-realaudio• audio/x-ms-wma• video/x-ms-asf• application/octet-stream

Page 17: © 2004 the University of Greenwich 1 Introduction to the Web and.NET Kevin McManus Adapted from material by Mark Sapossnek Computer Science Department.

© 2004 the University of Greenwich 17

Internet TechnologiesMIME

• Specifies character sets, e.g. ASCII

• Supports multi-part messages

• Originally designed for email, but also used in other places, such as HTTP

Page 18: © 2004 the University of Greenwich 1 Introduction to the Web and.NET Kevin McManus Adapted from material by Mark Sapossnek Computer Science Department.

© 2004 the University of Greenwich 18

Internet TechnologiesBrowsers

• Client-side application• also known as a User Agent

• Forms HTTP requests on behalf of users• Can render HTML

• usually graphical but may be text only

• Popular browsers:• Mozilla• Netscape• Internet Explorer• Opera

• Assistive technology• specialised to provide access for people with disability

Page 19: © 2004 the University of Greenwich 1 Introduction to the Web and.NET Kevin McManus Adapted from material by Mark Sapossnek Computer Science Department.

© 2004 the University of Greenwich 19

Internet TechnologiesClients & Servers

• Client and Server computers both have:• CPU• Memory• I/O

• Disks• Network

• Bus• Multi-tasking operating system• Applications

Page 20: © 2004 the University of Greenwich 1 Introduction to the Web and.NET Kevin McManus Adapted from material by Mark Sapossnek Computer Science Department.

© 2004 the University of Greenwich 20

Internet TechnologiesClients & Servers

• Clients• Generally supports a single user• Optimized for responsiveness to user• User interface, graphics

• Servers• Supports multiple users• Optimized for throughput• More: CPUs (SMP), memory, disks (SANs), I/O• Provide services (e.g. Web, file, print, database,

e-mail, fax, transaction, telnet, directory)

Page 21: © 2004 the University of Greenwich 1 Introduction to the Web and.NET Kevin McManus Adapted from material by Mark Sapossnek Computer Science Department.

© 2004 the University of Greenwich 21

Internet TechnologiesProxy Servers & Firewalls

• Proxy Server • A server that sits between a client (running a browser)

and the Internet• Improves performance by caching commonly used

Web pages• Can filter requests to prevent users from accessing

certain Web sites

• Firewall• A server that sits between a network and the Internet

to prevent unauthorized access to the network from the Internet

Page 22: © 2004 the University of Greenwich 1 Introduction to the Web and.NET Kevin McManus Adapted from material by Mark Sapossnek Computer Science Department.

© 2004 the University of Greenwich 22

Internet TechnologiesNetworks

• Network = an interconnected collection of independent computers

• Why have networks?• Resource sharing• Reliability• Cost savings• Communication

• Web technologies add:• New business models: e-commerce, advertising• Entertainment• Applications without a client-side install

Page 23: © 2004 the University of Greenwich 1 Introduction to the Web and.NET Kevin McManus Adapted from material by Mark Sapossnek Computer Science Department.

© 2004 the University of Greenwich 23

Internet TechnologiesNetworks

• Network scope• internet: a collection of connected networks• Internet: a specific world-wide network based on

TCP/IP, used to connect companies, universities, governments, organizations and individuals. Originated as ARPANET, funded by the US DoD.

• intranet: a network based on Internet technologies that is internal to a company or organization

• extranet: a network based on Internet technologies that connects one company or organization to another

Page 24: © 2004 the University of Greenwich 1 Introduction to the Web and.NET Kevin McManus Adapted from material by Mark Sapossnek Computer Science Department.

© 2004 the University of Greenwich 24

Internet TechnologiesNetworks

• Network technology is largely determined by scale:• Local Area Network (LAN): Span up to a few

kilometers. Bus vs. ring topologies• Wide Area Networks (WAN): Can span a

country or continent. WANs use routers as intermediate nodes to connect transmission lines

Page 25: © 2004 the University of Greenwich 1 Introduction to the Web and.NET Kevin McManus Adapted from material by Mark Sapossnek Computer Science Department.

© 2004 the University of Greenwich 25

Internet TechnologiesNetworks

• Network technology• Broadcasting

• Packets of data are sent from one machine and received by all computers on the network

• Multicast: packets are received by a subset of the machines on a network

• Point-to-point• Packets have to be routed from one machine to another;

there many be many paths

• In general, geographically localized networks use broadcasting, while disperse networks use point-to-point

Page 26: © 2004 the University of Greenwich 1 Introduction to the Web and.NET Kevin McManus Adapted from material by Mark Sapossnek Computer Science Department.

© 2004 the University of Greenwich 26

Internet TechnologiesNetworks

ApplicationLayer

PresentationLayer

SessionLayer

TransportLayer

NetworkLayer

Data LinkLayer

PhysicalLayer

InternetLayer

ApplicationLayer

Telnet FTP SMTP DNS RIP SNMP HTTP

IP

Host-to-HostTransport

LayerTCP UDP

TokenRing

Ethernet ATMFrameRelay

NetworkInterface

Layer

OSI Model Layers

TCP/IP Protocol

Architecture Layers

TCP/IP Protocol Suite

ARPICMPIGMP

Telnet FTP SMTP DNS RIP SNMP

TCP

Page 27: © 2004 the University of Greenwich 1 Introduction to the Web and.NET Kevin McManus Adapted from material by Mark Sapossnek Computer Science Department.

© 2004 the University of Greenwich 27

Internet TechnologiesNetwork Protocol Stack

HTTP

TCP

IP

Ethernet

HTTP

TCP

IP

Ethernet

Page 28: © 2004 the University of Greenwich 1 Introduction to the Web and.NET Kevin McManus Adapted from material by Mark Sapossnek Computer Science Department.

© 2004 the University of Greenwich 28

Internet TechnologiesNetworks - Internet Layer

• Internet Protocol (IP)

• Responsible for getting packets from source to destination across multiple hops

• Not reliable

• IP address: 32 bit value usually written in dotted decimal notation as four 8-bit numbers (0 to 255); e.g. 130.50.12.4

Page 29: © 2004 the University of Greenwich 1 Introduction to the Web and.NET Kevin McManus Adapted from material by Mark Sapossnek Computer Science Department.

© 2004 the University of Greenwich 29

Internet TechnologiesNetworks - Transport Layer

• Provides efficient, reliable and cost-effective service

• Uses the Sockets programming model• Ports identify application

• Well-known ports identify standard services (e.g. HTTP uses port 80, SMTP uses port 25)

• Transmission Control Protocol (TCP)• Provides reliable, connection-oriented byte stream

• UDP• Connectionless, unreliable

Page 30: © 2004 the University of Greenwich 1 Introduction to the Web and.NET Kevin McManus Adapted from material by Mark Sapossnek Computer Science Department.

© 2004 the University of Greenwich 30

Internet TechnologiesNetworks - Application Layer

• Telnet: Remote sessions

• File Transfer Protocol (FTP)

• Network News Transfer Protocol (NNTP)

• Simple Network Management Protocol (SNMP)

• Simple Mail Transfer Protocol (SMTP)

• Post Office Protocol (POP3)

• Interactive Mail Access Protocol (IMAP)

Page 31: © 2004 the University of Greenwich 1 Introduction to the Web and.NET Kevin McManus Adapted from material by Mark Sapossnek Computer Science Department.

© 2004 the University of Greenwich 31

Internet TechnologiesNetworks - Domain Name System (DNS)

• Provides user-friendly domain names, e.g. www.msn.com

• Hierarchical name space with limited root names

• DNS servers map domain names to IP addresses

.com .net .gov .edu

.org .mil .jp .de

Page 32: © 2004 the University of Greenwich 1 Introduction to the Web and.NET Kevin McManus Adapted from material by Mark Sapossnek Computer Science Department.

© 2004 the University of Greenwich 32

Internet TechnologiesExtensible Markup Language (XML)

• Represents hierarchical data

• A meta-language: a language for defining other languages

• Extensible

• Useful for data exchange and transformation

• Simplified version of SGML

Page 33: © 2004 the University of Greenwich 1 Introduction to the Web and.NET Kevin McManus Adapted from material by Mark Sapossnek Computer Science Department.

© 2004 the University of Greenwich 33

Agenda

• Internet Technologies

• Programming Languages and Paradigms

• Programming the Web

• .NET Overview

Page 34: © 2004 the University of Greenwich 1 Introduction to the Web and.NET Kevin McManus Adapted from material by Mark Sapossnek Computer Science Department.

© 2004 the University of Greenwich 34

Programming Languages

• Machine code• Assembly language• High-level languages

• Fortran, LISP, Cobol• C, Pascal, Basic, Smalltalk• C++, Eiffel• Java, C#

• Scripting languages• Shell scripts, Perl, TCL, Python, JavaScript, VBScript

Page 35: © 2004 the University of Greenwich 1 Introduction to the Web and.NET Kevin McManus Adapted from material by Mark Sapossnek Computer Science Department.

© 2004 the University of Greenwich 35

Programming Paradigms

• Unstructured programming

• Structured programming

• Object-oriented programming

• Component-based programming

• Event-based programming

Page 36: © 2004 the University of Greenwich 1 Introduction to the Web and.NET Kevin McManus Adapted from material by Mark Sapossnek Computer Science Department.

© 2004 the University of Greenwich 36

Programming ParadigmsUnstructured Programming

• See “Go To Statement Considered Harmful” at http://www.acm.org/classics/oct95/

Page 37: © 2004 the University of Greenwich 1 Introduction to the Web and.NET Kevin McManus Adapted from material by Mark Sapossnek Computer Science Department.

© 2004 the University of Greenwich 37

Programming ParadigmsStructured Programming

• Sequence• Conditional

• if then else• switch

• Looping• for i from 1 to n• do while• do until

• Functions• Exceptions

Page 38: © 2004 the University of Greenwich 1 Introduction to the Web and.NET Kevin McManus Adapted from material by Mark Sapossnek Computer Science Department.

© 2004 the University of Greenwich 38

Programming ParadigmsObject-Oriented Programming

• Objects have data and behavior• Data: members, fields, variables, slots, properties

• Behavior: methods, functions, procedures

• Using objects is easy• First instantiate the type of object desired

• Then call its methods and get/set its properties

• Designing new types of objects can be hard• Design goals often conflict: simplicity, functionality,

reuse, performance

Page 39: © 2004 the University of Greenwich 1 Introduction to the Web and.NET Kevin McManus Adapted from material by Mark Sapossnek Computer Science Department.

© 2004 the University of Greenwich 39

Programming ParadigmsObject-Oriented Programming

• Key object-oriented concepts• Identity• Encapsulation

• Data + behavior• Information hiding (abstraction)

• Classes vs. instances• Polymorphism• Interfaces• Delegation, aggregation• Inheritance• Patterns

Page 40: © 2004 the University of Greenwich 1 Introduction to the Web and.NET Kevin McManus Adapted from material by Mark Sapossnek Computer Science Department.

© 2004 the University of Greenwich 40

Programming ParadigmsComponent-Based Programming

• Components• Independent modules of reuse and deployment• Coarser-grained than objects

(objects are language-level constructs)• Includes multiple classes• Often language-independent

• In the general case, the component writer and the component user don’t know each other, don’t work for the same company, and don’t use the same language

Page 41: © 2004 the University of Greenwich 1 Introduction to the Web and.NET Kevin McManus Adapted from material by Mark Sapossnek Computer Science Department.

© 2004 the University of Greenwich 41

Programming ParadigmsComponent-Based Programming

• Component Object Model (COM)• Initial Microsoft standard for components• Specifies a protocol for instantiating and using

components in-process, across processes or across machine boundaries

• Basis for ActiveX, OLE, and many other technologies• Can be created in Visual Basic, C++, .NET, …

• Java Beans• Java standard for components• Not language-independent

Page 42: © 2004 the University of Greenwich 1 Introduction to the Web and.NET Kevin McManus Adapted from material by Mark Sapossnek Computer Science Department.

© 2004 the University of Greenwich 42

Programming ParadigmsEvent-Based Programming

• When something of interest occurs, an event is raised and application-specific code is executed

• Events provide a way for you to hook in your own code into the operation of another system

• Event = callback• User interfaces are all about events

• onClick, onMouseOver, onMouseMove…

• Events can also be based upon time or interactions with the network, operating system, other applications, etc.

Page 43: © 2004 the University of Greenwich 1 Introduction to the Web and.NET Kevin McManus Adapted from material by Mark Sapossnek Computer Science Department.

© 2004 the University of Greenwich 43

Agenda

• Internet Technologies

• Programming Languages and Paradigms

• Programming the Web

• .NET Overview

Page 44: © 2004 the University of Greenwich 1 Introduction to the Web and.NET Kevin McManus Adapted from material by Mark Sapossnek Computer Science Department.

© 2004 the University of Greenwich 44

Programming the WebClient-Side Code

• What is client-side code?• Software that is downloaded from Web server to

browser and then executes on the client

• Why client-side code?• Better scalability: less work done on server• Better performance/user experience• Create UI constructs not inherent in HTML

• Drop-down and pull-out menus• Tabbed dialogs

• Cool effects, e.g. animation• Data validation

Page 45: © 2004 the University of Greenwich 1 Introduction to the Web and.NET Kevin McManus Adapted from material by Mark Sapossnek Computer Science Department.

© 2004 the University of Greenwich 45

Programming the WebClient-Side Technologies

• DHTML – HTML + CSS + JavaScript + DOM• COM

• ActiveX controls• COM components• Remote Data Services (RDS)

• Java applets• Plug-ins, e.g. shockwave• Helpers• Remote Scripting, e.g. AMF

Page 46: © 2004 the University of Greenwich 1 Introduction to the Web and.NET Kevin McManus Adapted from material by Mark Sapossnek Computer Science Department.

© 2004 the University of Greenwich 46

Programming the WebDynamic HTML (DHTML)

• Script that is embedded within an HTML page• Usually written in JavaScript (ECMAScript,

JScript) for portability• Internet Explorer also supports VBScript and other

scripting languages

• Each HTML element is an object in the DOM that has associated events (e.g. onClick)

• Script provides code to respond to browser events

Page 47: © 2004 the University of Greenwich 1 Introduction to the Web and.NET Kevin McManus Adapted from material by Mark Sapossnek Computer Science Department.

© 2004 the University of Greenwich 47

Programming the WebDHTML

• DHTML Document Object Model (DOM)

window

history document location screen

all location children selectionforms body links

text buttonradio textarea select

password

file

checkbox submit

resetoption

navigator framesevent

Page 48: © 2004 the University of Greenwich 1 Introduction to the Web and.NET Kevin McManus Adapted from material by Mark Sapossnek Computer Science Department.

© 2004 the University of Greenwich 48

Programming the WebActiveX

• Based on COM• Native only to Internet Explorer

• Supported in other browsers with a plug-in

• Good when you know your users (e.g. intranet) or can specify which browser to use• Not so good when you don’t (e.g. the Internet)

• Small, efficient code• Like Flash but not so pretty

Page 49: © 2004 the University of Greenwich 1 Introduction to the Web and.NET Kevin McManus Adapted from material by Mark Sapossnek Computer Science Department.

© 2004 the University of Greenwich 49

Programming the WebJava Applets

• Based on Java bytecode

• Held great promise as a portable, pain-free way to download client-side code: • “Write once, run anywhere”

• Fairly safe: code runs in a “sandbox”

• Compatibility and performance issues have prevented common usage

Page 50: © 2004 the University of Greenwich 1 Introduction to the Web and.NET Kevin McManus Adapted from material by Mark Sapossnek Computer Science Department.

© 2004 the University of Greenwich 50

Programming the WebServer-Side Code

• What is server-side code?• Software that runs on the server, not the client• Receives input from

• URL parameters• HTML form data• Cookies• HTTP headers

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

• Dynamically builds a custom HTML response for a client

Page 51: © 2004 the University of Greenwich 1 Introduction to the Web and.NET Kevin McManus Adapted from material by Mark Sapossnek Computer Science Department.

© 2004 the University of Greenwich 51

Programming the WebServer-Side Code

• Why server-side code?• Availability

• You can reach the Internet from any browser, any device, any time, anywhere

• Manageability• Does not require distribution of application code• Easy to change code

• Security• Source code is not exposed• Once user is authenticated, can only allow certain actions

• Scalability• Web-based 3-tier architecture can scale out

Page 52: © 2004 the University of Greenwich 1 Introduction to the Web and.NET Kevin McManus Adapted from material by Mark Sapossnek Computer Science Department.

© 2004 the University of Greenwich 52

Programming the WebServer-Side Technologies

• Common Gateway Interface (CGI)• not language specific

• Internet Server API (ISAPI)• netscape Server API (NSAPI)

• Active Server Pages (ASP)• now obsolete

• Java Server Pages (JSP)• PHP Hypertext Processor (PHP)• Cold Fusion (CFM)

• actually J2EE with the arrival of ColdFusion MX• ASP.NET

Page 53: © 2004 the University of Greenwich 1 Introduction to the Web and.NET Kevin McManus Adapted from material by Mark Sapossnek Computer Science Department.

© 2004 the University of Greenwich 53

Programming the Web Active Server Pages (ASP)

• Technology to easily create server-side applications

• ASP pages are written in a scripting language• usually VBScript but also Jscript or PerlScript

• An ASP page contains static HTML interspersed with server-side code

• ASP script is commonly used to access and update a database• 3-tier systems

Page 54: © 2004 the University of Greenwich 1 Introduction to the Web and.NET Kevin McManus Adapted from material by Mark Sapossnek Computer Science Department.

© 2004 the University of Greenwich 54

Programming the WebASP

HTTP request(form data, HTTP

header data)

HTTP responseHTML, XML

ASP page(static HTML +

server-side logic)

Page 55: © 2004 the University of Greenwich 1 Introduction to the Web and.NET Kevin McManus Adapted from material by Mark Sapossnek Computer Science Department.

© 2004 the University of Greenwich 55

Agenda

• Internet Technologies

• Programming Languages and Paradigms

• Programming the Web

• .NET Overview

Page 56: © 2004 the University of Greenwich 1 Introduction to the Web and.NET Kevin McManus Adapted from material by Mark Sapossnek Computer Science Department.

© 2004 the University of Greenwich 56

.NET Overview

• Introduction to .NET

• Web Services

• The .NET Framework

• Common Language Runtime

• Windows Forms

• Web Forms

• ADO.NET

• Languages

Page 57: © 2004 the University of Greenwich 1 Introduction to the Web and.NET Kevin McManus Adapted from material by Mark Sapossnek Computer Science Department.

© 2004 the University of Greenwich 57

Introduction to .NETWhat is .NET?

• A vision• web sites will be joined by web services• new smart devices will join the PC• user interfaces will become more adaptable

and customizable• enabled by web standards

Page 58: © 2004 the University of Greenwich 1 Introduction to the Web and.NET Kevin McManus Adapted from material by Mark Sapossnek Computer Science Department.

© 2004 the University of Greenwich 58

• A platform• the .NET Framework• Visual Studio.NET• .NET Enterprise Servers

• database, messaging, integration, commerce, proxy, security, mobility, orchestration, content management

• .NET Building Block Services• Passport• .NET My Services (“Hailstorm”)

• goal: make it incredibly easy to build powerful web applications and web services

Introduction to .NETWhat is .NET?

} The focus of this course

Page 59: © 2004 the University of Greenwich 1 Introduction to the Web and.NET Kevin McManus Adapted from material by Mark Sapossnek Computer Science Department.

© 2004 the University of Greenwich 59

• A business model• software as a service• subscription-based services• application hosting

Introduction to .NETWhat is .NET?

Page 60: © 2004 the University of Greenwich 1 Introduction to the Web and.NET Kevin McManus Adapted from material by Mark Sapossnek Computer Science Department.

© 2004 the University of Greenwich 60

Introduction to .NETThe .NET Platform

Web Form

.NET Framework

Windows and Linux and…

Web Service

.NET FoundationWeb Services

Your InternalWeb Service

Third-PartyWeb Services

.NET EnterpriseServers

Clients Applications

Protocols: HTTP,HTML, XML, SOAP, UDDI

Tools:Visual Studio.NET,

Notepad

Page 61: © 2004 the University of Greenwich 1 Introduction to the Web and.NET Kevin McManus Adapted from material by Mark Sapossnek Computer Science Department.

© 2004 the University of Greenwich 61

Web Services

• A programmable application component accessible via standard web protocols

• The centre of the .NET architecture

• Exposes functionality over the Web

• Built on existing and emerging standards• HTTP, XML, SOAP, UDDI, WSDL, …

Page 62: © 2004 the University of Greenwich 1 Introduction to the Web and.NET Kevin McManus Adapted from material by Mark Sapossnek Computer Science Department.

© 2004 the University of Greenwich 62

Web ServicesEvolution of the Web

Generation 1Static HTML

HTML

Generation 2Web Applications

HTML

HTML, XML

HTML, XML

Generation 3Web Services

Page 63: © 2004 the University of Greenwich 1 Introduction to the Web and.NET Kevin McManus Adapted from material by Mark Sapossnek Computer Science Department.

© 2004 the University of Greenwich 63

• A set of technologies for developing and using components to create:• web forms• web services• windows applications

• Supports the software lifecycle• development• debugging• deployment • maintenance

The .NET FrameworkWhat Is the .NET Framework?

Page 64: © 2004 the University of Greenwich 1 Introduction to the Web and.NET Kevin McManus Adapted from material by Mark Sapossnek Computer Science Department.

© 2004 the University of Greenwich 64

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

The .NET FrameworkThe .NET Framework and Visual Studio.NET

Page 65: © 2004 the University of Greenwich 1 Introduction to the Web and.NET Kevin McManus Adapted from material by Mark Sapossnek Computer Science Department.

© 2004 the University of Greenwich 65

System.Data

DesignOLEDB

SQLTypesSQL

System

GlobalizationDiagnostics

ConfigurationCollections

ResourcesReflection

NetIO

ThreadingText

ServiceProcessSecurity Runtime

InteropServicesRemotingSerialization

System.Xml

XPathXSLT Serialization

System.Web

Configuration SessionStateCaching Security

ServicesDescriptionDiscoveryProtocols

UIHtmlControls

WebControlsSystem.Drawing

ImagingDrawing2D

TextPrinting

The .NET Framework.NET Framework Classes

System.Windows.FormsForm Button

MessageBox ListControl

Page 66: © 2004 the University of Greenwich 1 Introduction to the Web and.NET Kevin McManus Adapted from material by Mark Sapossnek Computer Science Department.

© 2004 the University of Greenwich 66

Common Language RuntimeGoals

• Development services• deep cross-language interoperability• increased productivity

• Deployment services• simple, reliable deployment• fewer versioning problems – NO MORE ‘DLL HELL’

• Run-time services• performance • scalability • availability

• reliability• security• safety

Page 67: © 2004 the University of Greenwich 1 Introduction to the Web and.NET Kevin McManus Adapted from material by Mark Sapossnek Computer Science Department.

© 2004 the University of Greenwich 67

Source CodeSource Code

C++, C#, VB or any .NET language

csc.exe or vbc.exe

Compiler

AssemblyAssembly

DLL or EXE

Common Language RuntimeCompilation

Page 68: © 2004 the University of Greenwich 1 Introduction to the Web and.NET Kevin McManus Adapted from material by Mark Sapossnek Computer Science Department.

© 2004 the University of Greenwich 68

• Assembly• logical unit of deployment• contains manifest, metadata, MSIL and resources

• Manifest• metadata about the components in an assembly

(version, types, dependencies, etc.)

• Type metadata• completely describes all types defined in

an assembly: properties, methods, arguments, return values, attributes, base classes, …

Common Language RuntimeAssemblies

Page 69: © 2004 the University of Greenwich 1 Introduction to the Web and.NET Kevin McManus Adapted from material by Mark Sapossnek Computer Science Department.

© 2004 the University of Greenwich 69

Common Language RuntimeAssemblies

• Microsoft Intermediate Language• MSIL or IL• all languages compile to IL (managed code)• IL is always compiled to native code before

being executed

• Resources• data, images, audio, etc.

Page 70: © 2004 the University of Greenwich 1 Introduction to the Web and.NET Kevin McManus Adapted from material by Mark Sapossnek Computer Science Department.

© 2004 the University of Greenwich 70

Common Language RuntimeExecution Model

CLR

VBSource code

Compiler

C++C#

Assembly AssemblyAssembly

Operating System Services

MSIL

Common Language Runtime JIT Compiler

Compiler Compiler

Nativecode

ManagedCode

ManagedCode

ManagedCode

UnmanagedCode

CLR Services

Ngen

Page 71: © 2004 the University of Greenwich 1 Introduction to the Web and.NET Kevin McManus Adapted from material by Mark Sapossnek Computer Science Department.

© 2004 the University of Greenwich 71

Common Language RuntimeServices

• Code management• Conversion of MSIL to

native code • Loading and execution of

managed code • Creation and

management of metadata• Verification of type safety• Insertion and execution of

security checks• Memory management

and isolation

• Garbage collection• Handling exceptions

across languages• Interoperation

between .NET Framework objects and COM objects and Win32 DLLs

• Automation of object layout for late binding

• Developer services (profiling, debugging, etc.)

Page 72: © 2004 the University of Greenwich 1 Introduction to the Web and.NET Kevin McManus Adapted from material by Mark Sapossnek Computer Science Department.

© 2004 the University of Greenwich 72

• Common Type System (CTS)• superset of the data types used by most modern programming

languages

• Common Language Specification (CLS)• subset of CTS that allows code written in different languages to

interoperate

• What languages?• Microsoft - C#, C++, VB.NET, JScript• third party

• Perl, Ada, Cobol, Java, Fortran• Eiffel, Smalltalk, Scheme, Oberon, Haskell, Python,…• only practical if the language supports some sort of encapsulation

Common Language RuntimeMultiple Language Support

Page 73: © 2004 the University of Greenwich 1 Introduction to the Web and.NET Kevin McManus Adapted from material by Mark Sapossnek Computer Science Department.

© 2004 the University of Greenwich 73

Common Language RuntimeApplications

• An application consists of one or more assemblies• How does one assembly bind to another?

• based upon metadata and policy• local (preferred)• Assembly Global Cache (AGC) (accurate garbage collection?)

• Multiple versions of an assembly may exist on the same machine• easier software deployment, updates and removal• multiple versions of an assembly can even be used by

the same application• like this is a new thing?

Page 74: © 2004 the University of Greenwich 1 Introduction to the Web and.NET Kevin McManus Adapted from material by Mark Sapossnek Computer Science Department.

© 2004 the University of Greenwich 74

Common Language RuntimeSecurity

• Evidence-based security (authentication)

• Based on user identity and code identity

• Configurable policies

• Imperative and declarative interfaces

Page 75: © 2004 the University of Greenwich 1 Introduction to the Web and.NET Kevin McManus Adapted from material by Mark Sapossnek Computer Science Department.

© 2004 the University of Greenwich 75

Windows Forms

• Framework for building rich clients

• Built upon .NET Framework, languages

• Rapid Application Development (RAD)

• Visual inheritance• Anchoring and docking• Rich set of controls

• Extensible controls• Data-aware• Easily hooked into

Web Services• ActiveX support• Licensing support• Printing support• Advanced graphics

Page 76: © 2004 the University of Greenwich 1 Introduction to the Web and.NET Kevin McManus Adapted from material by Mark Sapossnek Computer Science Department.

© 2004 the University of Greenwich 76

Web Forms• Built with ASP.NET

• logical evolution of ASP• similar development model: edit the page and go

• Requires less code• actually more code but less programming

• New programming model• event-driven/server-side controls• rich controls (e.g. data grid, validation)• data binding• controls generate browser-specific code• simplified handling of page state

Page 77: © 2004 the University of Greenwich 1 Introduction to the Web and.NET Kevin McManus Adapted from material by Mark Sapossnek Computer Science Department.

© 2004 the University of Greenwich 77

Web Forms

• Allows separation of UI and business logic• separation of concerns is a good thing• cleaner, more maintainable code

• Uses .NET languages• not just scripting

• Easy to use components

• XCOPY/FTP deployment

• Simple configuration (XML-based)

Page 78: © 2004 the University of Greenwich 1 Introduction to the Web and.NET Kevin McManus Adapted from material by Mark Sapossnek Computer Science Department.

© 2004 the University of Greenwich 78

Web Forms

• Caching (pages, fragments, custom)

• Scalable session state management

• Tracing support

• ASP.NET is extensible• no ISAPI / ASP dichotomy

• Automatic process rollover

• Forms-based authentication

Page 79: © 2004 the University of Greenwich 1 Introduction to the Web and.NET Kevin McManus Adapted from material by Mark Sapossnek Computer Science Department.

© 2004 the University of Greenwich 79

• Similar to ADO, but better factored• Language-neutral data access• Supports two styles of data access

• disconnected• forward-only, read-only access

• Supports data binding• DataSet: a collection of tables• Can view and process data relationally (tables) or

hierarchically (XML)

ADO.NETActiveX Data Objects

Page 80: © 2004 the University of Greenwich 1 Introduction to the Web and.NET Kevin McManus Adapted from material by Mark Sapossnek Computer Science Department.

© 2004 the University of Greenwich 80

Languages C#

• New language created for .NET• a Java rip-off

• Safe, productive evolution of C++• but not as safe as Java until M$ sort out the

exceptions

• Key concepts:• component-oriented• everything is an object• robust and durable code• preserving your investment

• Submitted to the ECMA for standardization

Page 81: © 2004 the University of Greenwich 1 Introduction to the Web and.NET Kevin McManus Adapted from material by Mark Sapossnek Computer Science Department.

© 2004 the University of Greenwich 81

Languages Visual Basic.NET

• Modernizes and simplifies Visual Basic• because the old VB was pants• inheritance• threading• exception handling

• Support for late binding• whatever that is

• Actually just C# with a different syntax• and some of the fancy stuff missing because VB

programmers are unlikely to be clever enough to use them anyway

Page 82: © 2004 the University of Greenwich 1 Introduction to the Web and.NET Kevin McManus Adapted from material by Mark Sapossnek Computer Science Department.

© 2004 the University of Greenwich 82

Conclusion• dotNET is pretty neat really even if it does come

from M$• A whole lot of good ideas have been gathered

together without the accumulation of legacy bugware that tends to plague other M$ products

• Although .NET initially looked like another attempt by Mr Evil to take over the world it is remarkably open and standard compliant compared with other M$ offerings

• The best bit is probably Visual Studio with it’s tooled up approach to application development

Page 83: © 2004 the University of Greenwich 1 Introduction to the Web and.NET Kevin McManus Adapted from material by Mark Sapossnek Computer Science Department.

© 2004 the University of Greenwich 83

More Resources• HTTP

• http://msdn.microsoft.com/library/periodic/period96/protocol.htm• HTTP Essentials, Stephen Thomas, 2001, Wiley,

ISBN 0471-39823-3

• Cookies• http://msdn.microsoft.com/library/default.asp?URL=/library/

partbook/instantj/cookies.htm

• MIME• http://www.ufaq.org/navcom/mime_tutorial.html• http://www.irvine.com/~mime/

• Networks• http://msdn.microsoft.com/library/periodic/period99/ntp99b3.htm

Page 84: © 2004 the University of Greenwich 1 Introduction to the Web and.NET Kevin McManus Adapted from material by Mark Sapossnek Computer Science Department.

© 2004 the University of Greenwich 84

More Resources• XML

• http://msdn.microsoft.com/xml/default.asp• http://www.w3.org/XML/• Essential XML, Don Box, Aaron Skonnard, John Lam,

Addison Wesley, 2000, ISBN 0-201-70914-7

• .NET• http://www.microsoft.com/net/• http://msdn.microsoft.com/net/• http://www.gotdotnet.com• msnews.microsoft.com news server

• microsoft.public.dotnet.general newsgroup