Vous êtes sur la page 1sur 42

Introduction to

ASP.NET
Kevin McManus
Adapted from material by Gill Windall and Mark Sapossnek
Introduction to ASP.NET

Contents
• An overview of what .NET is and some of its key
features
• Describe the areas of .NET likely to have an
impact on how web applications are developed
• What is Microsoft .NET?
• Some views
• Web Services
• ASP .NET versus ASP
• .NET Platform and .NET Framework
• Common Language Runtime (CLR)

© K.M. 2/11/2007 the University of Greenwich 2


Introduction to ASP.NET

What is Microsoft .NET?


that new language C#
Microsoft putting XML into
everything

the next version of Visual


Basic the next version of ASP

the next version of


Visual Studio
Microsoft trying to
kill Java

being able to run everything


across the Net
it’s a good thing

it’s rubbish!!!

© K.M. 2/11/2007 the University of Greenwich 3


Introduction to ASP.NET

What is Microsoft .NET?


• Initially announced as the latest release of everything
Microsoft
• ASP.NET, VB.NET, VisualStudio.NET
• With are some big changes
• the new language C#
• got rid of VB at last
• the Common Language Runtime (CLR)
• language integration - shared libraries
• possible platform independence – Mono CLR
• an attack on JRE
• ability to develop and use software components over the web
• XML based Web Services
• simplified deployment of Windoze software
• an end to DLL hell
• no use of the “registry”
• http://zdnet.com.com/2100-1104-991369.html
• no more mixing HTML and script code in ASP
© K.M. 2/11/2007 the University of Greenwich 4
Introduction to ASP.NET

Web Services
• Allow remote access to software components
• via standard web protocols
• Use XML to exchange structured data
• Microsoft .NET is just one implementation of Web
Services but there are many others
• The idea of Web Services is not exclusive to Microsoft
“Last Wednesday, Microsoft released a new software development program
called Visual Studio.Net. …. it represents the company's big leap into Web
services, which many hope will trigger the next generation of corporate
computing innovation. Microsoft spent $2 billion developing Visual Studio.Net
and C#, but just about every other technology company on the planet --
including IBM and Sun Microsystems -- is also placing big bets on Web
services.”
ZDNet Feb 2002

© K.M. 2/11/2007 the University of Greenwich 5


Introduction to ASP.NET

Web Services and Microsoft .NET


There are three main angles on this:
1. Microsoft plans to provide a number of Web Services
that application developers can use for a fee
• Microsoft .NET Passport - authentication service offers single
sign-on capability for any Web site
• now Windows Live ID
• Microsoft .NET My Services - set of user-centric, XML Web
services to manage, protect personal information e.g. Calendar,
Contact, Inbox
2. Using ASP.NET you can create Web Services that
others can use
3. Using a .NET language (or ASP.NET) you can write a
program that uses Web Services
© K.M. 2/11/2007 the University of Greenwich 6
Introduction to ASP.NET

Programming the Web


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
• Cookies
• HTTP headers
• Can access server-side databases, e-mail
servers, files, mainframes, etc.
• Dynamically builds a custom HTML response
for a client
© K.M. 2/11/2007 the University of Greenwich 7
Introduction to ASP.NET

Programming the Web


Server-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

© K.M. 2/11/2007 the University of Greenwich 8


Introduction to ASP.NET

Programming the Web


Server-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

© K.M. 2/11/2007 the University of Greenwich 9


Introduction to ASP.NET

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

© K.M. 2/11/2007 the University of Greenwich 10


Introduction to ASP.NET

Programming the Web


ASP

HTTP request HTTP response


(form data, HTTP HTML, XML
header data)

ASP page
(static HTML +
server-side logic)

© K.M. 2/11/2007 the University of Greenwich 11


Introduction to ASP.NET

Introduction to .NET
What 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

© K.M. 2/11/2007 the University of Greenwich 12


Introduction to ASP.NET

Introduction to .NET
What is .NET?

• A platform
• the .NET Framework
• Visual Studio.NET
• .NET Enterprise Servers
} The focus of
this course

• 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

© K.M. 2/11/2007 the University of Greenwich 13


Introduction to ASP.NET

Introduction to .NET
What is .NET?

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

© K.M. 2/11/2007 the University of Greenwich 14


Introduction to ASP.NET

Introduction to .NET
The .NET Platform

Clients Applications

Web Form Web Service

Protocols: HTTP, .NET Framework Tools:


HTML, XML, Visual Studio.NET,
SOAP, UDDI Notepad
Windows and Linux and…

Your Internal .NET Foundation Third-Party .NET Enterprise


Web Service Web Services Web Services Servers

© K.M. 2/11/2007 the University of Greenwich 15


Introduction to ASP.NET

The Microsoft .NET Platform

Visual Studio .NET

.NET Enterprise .NET .NET Services


Servers Framework
e.g. Microsoft
SQL Server 2005 CLR, C#, ASP.NET, Passport
Win Server 2003 etc.

Operating System e.g. Windows XP, Windows 2000, Linux

© K.M. 2/11/2007 the University of Greenwich 16


Introduction to ASP.NET

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, …

© K.M. 2/11/2007 the University of Greenwich 17


Introduction to ASP.NET

Web Services
Evolution of the Web

HTML, XML
HTML HTML

XML

Generation 1 Generation 2 Generation 3


Static HTML Web Applications Web Services

© K.M. 2/11/2007 the University of Greenwich 18


Introduction to ASP.NET

The .NET Framework


What Is the .NET Framework?
• 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
© K.M. 2/11/2007 the University of Greenwich 19
Introduction to ASP.NET

The Microsoft .NET Framework


XML based Web Forms
Web Services ASP.NET Windows
Forms

Library classes for accessing data and XML


(ADO.NET, SQL, XML, XSLT)

Library Framework Base classes


(IO, string, collections, security)

Common Language Runtime

© K.M. 2/11/2007 the University of Greenwich 20


Introduction to ASP.NET

The .NET Framework


The .NET Framework and Visual Studio.NET

VB C++ C# JScript …

Visual Studio.NET
Common Language Specification
ASP.NET: Web Services Windows
and Web Forms Forms
ADO.NET: Data and XML

.NET Framework Base Classes

Common Language Runtime

© K.M. 2/11/2007 the University of Greenwich 21


Introduction to ASP.NET

The .NET Framework


.NET Framework Classes
System.Web System.Windows.Forms
Services UI Form Button
Description HtmlControls MessageBox ListControl
Discovery WebControls
Protocols System.Drawing
Caching Security Drawing2D Printing
Configuration SessionState Imaging Text
System.Data System.Xml
OLEDB SQL XSLT Serialization
Design SQLTypes XPath
System
Collections IO Security Runtime
Configuration Net ServiceProcess InteropServices
Diagnostics Reflection Text Remoting
Globalization Resources Threading Serialization

© K.M. 2/11/2007 the University of Greenwich 22


Introduction to ASP.NET

Common Language Runtime


Goals
• Development services
• deep cross-language interoperability
• increased productivity
• Deployment services
• simple, reliable deployment
• fewer versioning problems – NO MORE ‘DLL HELL’
• Run-time services
• reliability
• performance
• scalability • security
• availability • safety

© K.M. 2/11/2007 the University of Greenwich 23


Introduction to ASP.NET

Common Language Runtime


• Programs can run on any platform for which the CLR has been
implemented
• just like the JVM
• The CLR is no longer only available for Microsoft operating systems
• there are initiatives to port to other platforms
• Mono on Linux released 24th Nov 2004
• There are many .NET languages
• Microsoft
• C# , C++, VB.NET, JScript
• Third Party
• Cobol, Fortran, Perl, Python, Smalltalk
• CLR gives language integration
• a class written in one language can be used by a class written in
another
• share exactly the same libraries
• one API to learn

© K.M. 2/11/2007 the University of Greenwich 24


Introduction to ASP.NET

Common Language Runtime


Compilation

Source Code Assembly

Compiler
C++, C#, VB or any csc.exe or vbc.exe DLL or EXE
.NET language

© K.M. 2/11/2007 the University of Greenwich 25


Introduction to ASP.NET

Common Language Runtime


Program written in any .NET supported language
C#, VB.NET, etc.

compil
e

Intermediate Language (IL) - like Java bytecode


(.exe or .dll)

Common Language Runtime


Loads and executes code, garbage collects etc

© K.M. 2/11/2007 the University of Greenwich 26


Introduction to ASP.NET

Common Language Runtime


Assemblies
• 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, …

© K.M. 2/11/2007 the University of Greenwich 27


Introduction to ASP.NET

Common Language Runtime


Assemblies

• Microsoft Intermediate Language


• MSIL or IL
• all languages compile to IL (managed code)
• IL is always compiled to native code before
being executed
• Just In Time (JIT) compilation
• Resources
• data, images, audio, etc.

© K.M. 2/11/2007 the University of Greenwich 28


Introduction to ASP.NET

Common Language Runtime


Execution Model
Source
VB C# C++
code
Compiler Compiler Compiler

MSIL Assembly Assembly Assembly

Ngen Common Language Runtime JIT Compiler

Native Managed Managed Managed Unmanaged


code Code CLR
Code Code Code
CLR Services

Operating System Services

© K.M. 2/11/2007 the University of Greenwich 29


Introduction to ASP.NET

Common Language Runtime


Services
• Code management
• Garbage collection
• Conversion of MSIL to
native code • Handling exceptions
• Loading and execution of across languages
managed code • Interoperation between
• Creation and .NET Framework objects,
COM objects and Win32
management of metadata
DLLs
• Verification of type safety
• Automation of object
• Insertion and execution of layout for late binding
security checks
• Developer services
• Memory management (profiling, debugging, etc.)
and isolation
© K.M. 2/11/2007 the University of Greenwich 30
Introduction to ASP.NET

Common Language Runtime


Multiple Language Support
• 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, Delphi
• Eiffel, Smalltalk, Scheme, Oberon, Haskell, Python,…
• only practical if the language supports some sort of encapsulation

© K.M. 2/11/2007 the University of Greenwich 31


Introduction to ASP.NET

Common Language Runtime


Applications
• 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?

© K.M. 2/11/2007 the University of Greenwich 32


Introduction to ASP.NET

Common Language Runtime


Security

• Evidence-based security (authentication)


• Based on user identity and code identity
• Configurable policies
• Imperative and declarative interfaces

© K.M. 2/11/2007 the University of Greenwich 33


Introduction to ASP.NET

Windows Forms
• Framework for building • Extensible controls
rich clients • Data-aware
• Built upon .NET • Easily hooked into
Framework, languages Web Services
• Rapid Application • ActiveX support
Development (RAD) • Licensing support
• Visual inheritance • Printing support
• Anchoring and docking • Advanced graphics
• Rich set of controls

© K.M. 2/11/2007 the University of Greenwich 34


Introduction to ASP.NET

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

© K.M. 2/11/2007 the University of Greenwich 35


Introduction to ASP.NET

Web Forms
• Allows separation of UI and business logic
• separation of concerns is a good thing
• cleaner, more maintainable code
• no more VB 
• Uses .NET languages
• not just scripting
• Easy to use components
• XCOPY/FTP deployment
• Simple configuration (XML-based)

© K.M. 2/11/2007 the University of Greenwich 36


Introduction to ASP.NET

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

© K.M. 2/11/2007 the University of Greenwich 37


Introduction to ASP.NET

ADO.NET
ActiveX Data Objects

• 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)

© K.M. 2/11/2007 the University of Greenwich 38


Introduction to ASP.NET

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
• whatever that means
• Submitted to the ECMA for standardization
© K.M. 2/11/2007 the University of Greenwich 39
Introduction to ASP.NET

Languages
Visual Basic.NET
• Modernizes and simplifies Visual Basic
• because the old VB was pants
• Now provides
• inheritance
• threading
• exception handling
• Support for late binding
• whatever that is
• Actually just C# with a different syntax
• almost
© K.M. 2/11/2007 the University of Greenwich 40
Introduction to ASP.NET

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 is observed in 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

© K.M. 2/11/2007 the University of Greenwich 41


Introduction to ASP.NET

More Resources
• .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
• XML
• http://msdn.microsoft.com/xml/default.asp
• http://www.w3.org/XML/

© K.M. 2/11/2007 the University of Greenwich 42

Vous aimerez peut-être aussi