View
220
Download
0
Embed Size (px)
Citation preview
Introduction to ASP.NET
Kevin McManus Adapted from material by Gill Windall and Mark Sapossnek
© K.M. 2/11/2007 the University of Greenwich 2
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 3
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 4
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 5
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 6
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 7
Introduction to ASP.NET
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
© K.M. 2/11/2007 the University of Greenwich 8
Introduction to ASP.NET
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
© K.M. 2/11/2007 the University of Greenwich 9
Introduction to ASP.NET
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
© K.M. 2/11/2007 the University of Greenwich 10
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 11
Introduction to ASP.NET
Programming the WebASP
HTTP request(form data, HTTP
header data)
HTTP responseHTML, XML
ASP page(static HTML +
server-side logic)
© K.M. 2/11/2007 the University of Greenwich 12
Introduction to ASP.NET
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
© K.M. 2/11/2007 the University of Greenwich 13
Introduction to ASP.NET
• 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
© K.M. 2/11/2007 the University of Greenwich 14
Introduction to ASP.NET
• A business model• software as a service• subscription-based services• application hosting
Introduction to .NETWhat is .NET?
© K.M. 2/11/2007 the University of Greenwich 15
Introduction to ASP.NET
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
© K.M. 2/11/2007 the University of Greenwich 16
Introduction to ASP.NET
The Microsoft .NET Platform
Visual Studio .NET
.NET Enterprise Servers
SQL Server 2005Win Server 2003
.NET Framework
CLR, C#, ASP.NET, etc.
.NET Services
e.g. Microsoft Passport
Operating System e.g. Windows XP, Windows 2000, Linux
© K.M. 2/11/2007 the University of Greenwich 17
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 18
Introduction to ASP.NET
Web ServicesEvolution of the Web
Generation 2Web Applications
HTML
Generation 1Static HTML
HTML
HTML, XML
Generation 3Web Services
XML
© K.M. 2/11/2007 the University of Greenwich 19
Introduction to ASP.NET
• 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?
© K.M. 2/11/2007 the University of Greenwich 20
Introduction to ASP.NET
The Microsoft .NET Framework
XML based Web Services
Web Forms 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 21
Introduction to ASP.NET
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
© K.M. 2/11/2007 the University of Greenwich 22
Introduction to ASP.NET
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
© K.M. 2/11/2007 the University of Greenwich 23
Introduction to ASP.NET
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
© K.M. 2/11/2007 the University of Greenwich 24
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 25
Introduction to ASP.NET
Source CodeSource Code
C++, C#, VB or any .NET language
csc.exe or vbc.exe
Compiler
AssemblyAssembly
DLL or EXE
Common Language RuntimeCompilation
© K.M. 2/11/2007 the University of Greenwich 26
Introduction to ASP.NET
Common Language Runtime
Program written in any .NET supported language
C#, VB.NET, etc.
Intermediate Language (IL) - like Java bytecode
(.exe or .dll)
compile
Common Language Runtime
Loads and executes code, garbage collects etc
© K.M. 2/11/2007 the University of Greenwich 27
Introduction to ASP.NET
• 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
© K.M. 2/11/2007 the University of Greenwich 28
Introduction to ASP.NET
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• Just In Time (JIT) compilation
• Resources• data, images, audio, etc.
© K.M. 2/11/2007 the University of Greenwich 29
Introduction to ASP.NET
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
© K.M. 2/11/2007 the University of Greenwich 30
Introduction to ASP.NET
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, COM objects and Win32 DLLs
• Automation of object layout for late binding
• Developer services (profiling, debugging, etc.)
© K.M. 2/11/2007 the University of Greenwich 31
Introduction to ASP.NET
• 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
Common Language RuntimeMultiple Language Support
© K.M. 2/11/2007 the University of Greenwich 32
Introduction to ASP.NET
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?
© K.M. 2/11/2007 the University of Greenwich 33
Introduction to ASP.NET
Common Language RuntimeSecurity
• 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 34
Introduction to ASP.NET
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
© K.M. 2/11/2007 the University of Greenwich 35
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 36
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 37
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 38
Introduction to ASP.NET
• 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
© K.M. 2/11/2007 the University of Greenwich 39
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 40
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 41
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 42
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/