ASP.net Architecture Jeremy Boyd, Senior Technical Lead - Intergen MSDN Regional Director – New Zealand.

Slides:



Advertisements
Similar presentations
Tahir Nawaz Introduction to.NET Framework. .NET – What Is It? Software platform Language neutral In other words:.NET is not a language (Runtime and a.
Advertisements

Session 13 Active Server Pages (ASP) Matakuliah: M0114/Web Based Programming Tahun: 2005 Versi: 5.
11 ASP.NET Slides based off:. 22 B ACKGROUND - W EB A RCHITECTURE Web Server PC/Mac/Unix/... + Browser Client Server Request:
ASP.NET (Active Server Page) SNU OOPSLA Lab. October 2005.
Building Applications using ASP.NET and C# / Session 1 / 1 of 21 Session 1.
Anatomy of an ASP.NET Page. Slide 2 My Version of the Big Picture (1) ASP Worker (Engine) Your application Runs Server Other applications User 1User 2.
1 Chapter 12 Working With Access 2000 on the Internet.
Web Development Using ASP.NET CA – 240 Kashif Jalal Welcome to week – 1.1 of…
28/1/2001 Seminar in Databases in the Internet Environment Introduction to J ava S erver P ages technology by Naomi Chen.
Web Platform Introduction With a focus on “free” Mike Taulty Developer & Platform Group Microsoft Ltd
Kashif Jalal CA-240 (072) Web Development Using ASP.NET CA – 240 Kashif Jalal Welcome to week – 2 of…
Chapter 11 ASP.NET JavaScript, Third Edition. 2 Objectives Learn about client/server architecture Study server-side scripting Create ASP.NET applications.
Building Scalable and Reliable Web Applications Vineet Gupta Technology Evangelist Microsoft Corporation
Joe Hummel, PhD Dept of Mathematics and Computer Science Lake Forest College Lecture 8: WebForms — Web-based.
Tutorial: Introduction to ASP.NET Internet Technologies and Web Application 4 th February 2010.
FALL 2005CSI 4118 – UNIVERSITY OF OTTAWA1 Part 4 Web technologies: HTTP, CGI, PHP,Java applets)
© 2004 by The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill/Irwin Programming the Web Using ASP.Net Chapter 2: The ASP.Net Template Dave.
Architecture Of ASP.NET. What is ASP?  Server-side scripting technology.  Files containing HTML and scripting code.  Access via HTTP requests.  Scripting.
CIS 375—Web App Dev II ASP.NET 2 Introducing Web Forms.
Introduction to ASP.NET. Prehistory of ASP.NET Original Internet – text based WWW – static graphical content  HTML (client-side) Need for interactive.
Dr. Azeddine Chikh IS444: Modern tools for applications development.
Object-Oriented Application Development Using VB.NET 1 Chapter 12 Web Forms, HTML, and ASP.NET.
1 ASP.NET. 2 ASP.NET Architecture ASP.NET uses the CLR to replace the existing ISAPI/ASP infrastructure of IIS with a more efficient and easier-to-use.
An Introduction to ASP.NET Ed Dunhill blogs.msdn.com/edunhill SLIDE7.
Basics of Web Databases With the advent of Web database technology, Web pages are no longer static, but dynamic with connection to a back-end database.
Overview of Previous Lesson(s) Over View  ASP.NET Pages  Modular in nature and divided into the core sections  Page directives  Code Section  Page.
ASP.NET The.NET Framework. The.NET Framework is Microsoft’s distributed run-time environment for creating, deploying, and using applications over the.
Meir Botner David Ben-David. Project Goal Build a messenger that allows a customer to communicate with a service provider for a fee.
Native Support for Web Services  Native Web services access  Enables cross platform interoperability  Reduces middle-tier dependency (no IIS)  Simplifies.
1 Web Forms Andy Scrase.NET developer, Christchurch NZ
ASP.NET  ASP.NET is a web development platform, which provides a programming model, a comprehensive software infrastructure and various services required.
Beginning Web Site Development Module 1 – Dynamic Web Site Development Fundamentals of building dynamic Web sites with ASP.NET 2.0 and C# Version.
9 Chapter Nine Compiled Web Server Programs. 9 Chapter Objectives Learn about Common Gateway Interface (CGI) Create CGI programs that generate dynamic.
Introduction to ASP.NET 1www.tech.findforinfo.com.
DEV402 Extending the ASP.NET Runtime Jurgen Postelmans Microsoft Regional Director BeLux U2U.
The Web Architecture and ASP.NET. Slide 2 Review of the Web (1) It began with HTTP and HTML, which delivers static Web pages to browsers which would render.
Murach’s ASP.NET 4.0/VB, C1© 2006, Mike Murach & Associates, Inc.Slide 1.
Cross-Language Demo Demonstrates mixing C# and VB.NET code C# Class CSDemoClass.cs VB.NET Class VBDemoClass.vb “Main” class (C#) Demo.cs.
COMP3241 E-Business Technologies Richard Henson University of Worcester October 2012.
Introducing ASP.NET 2.0. Internet Technologies WWW Architecture Web Server Client Server Request Response Network HTTP TCP/IP PC/Mac/Unix + Browser (IE,
Active Server Pages (ASP), also known as Classic ASP or ASP Classic, was Microsoft's first server-side script engine for dynamically generated web pages.
WEB320 Migrating ASP.NET 1.x Applications to ASP.NET 2.0 Stefan Schackow Program Manager Web Platform and Tools Team Microsoft Corporation.
VITALE, CATURANO & COMPANY LTD Microsoft SharePoint Web Part Development Overview VITALE, CATURANO & COMPANY LTD SharePoint Developer Series – Web Part.
PAGE DIRECTIVES. Page Directives  They are instructions, inserted at the top of an ASP.NET page, to control the behavior of ASP.NET pages.  So it is.
ASP (Active Server Pages) by Bülent & Resul. Presentation Outline Introduction What is an ASP file? How does ASP work? What can ASP do? Differences Between.
ASP.NET in Definition: 1.ASP.NET is a web application framework developed and marketed by Microsoft to allow programmers to build dynamic web sites,
The Problem of State. We will look at… Sometimes web development is just plain weird! Internet / World Wide Web Aspects of their operation The role of.
ASP.NET (Active Server Page) SNU OOPSLA Lab. October 2005.
Understanding Web Applications Lesson 4. Objective Domain Matrix Skills/ConceptsMTA Exam Objectives Understanding Web Page Development Understand Web.
Introduction to ASP.NET What is ASP.NET and how is different from ASP –ASP: server side technology for creating dynamic web pages using scripting languages.
WEB SERVER SOFTWARE FEATURE SETS
WEB322 ASP.NET Internals: Under the Covers – Exploring Internals, Page Lifecycle and the Compilation Model Simon Calvert Program Manager Web Platform and.
ASP-2-1 SERVER AND CLIENT SIDE SCRITPING Colorado Technical University IT420 Tim Peterson.
Migrating ASP to ASP.NET Matt Gibbs ASP.NET Development Manager.
Overview of Previous Lesson(s) Over View  ASP is a technology that enables scripts in web pages to be executed by an Internet server.  ASP.NET is a.
Svetlin Nakov Telerik Corporation
1 ASP.NET Internals
Introduction to ASP.NET development. Background ASP released in 1996 ASP supported for a minimum 10 years from Windows 8 release ASP.Net 1.0 released.
Alexey Polovinkin Post graduate student, CMC department.
Introduction to ASP.NET, Second Edition2 Chapter Objectives.
ASP.NET Architecture Mike Taulty Developer & Platform Group Microsoft Ltd
A S P. Outline  The introduction of ASP  Why we choose ASP  How ASP works  Basic syntax rule of ASP  ASP’S object model  Limitations of ASP  Summary.
Computing with C# and the .NET Framework
Web Forms, HTML, and ASP.NET
Introduction to Client-Server Programming
Moving from ASP to ASP.NET
Web Development Using ASP .NET
Anatomy of an ASP.NET Page
Serpil TOK, Zeki BAYRAM. Eastern MediterraneanUniversity Famagusta
ASP.NET Imran Rashid CTO at ManiWeber Technologies.
Presentation transcript:

ASP.net Architecture Jeremy Boyd, Senior Technical Lead - Intergen MSDN Regional Director – New Zealand

A quick word about the RD program Regional Directors aren't Microsoft employees RDs are independent developers who provide a link between Microsoft and the local community. Find out more: Drop us a line if you want to talk shop, ask about the new technology coming out of Microsoft, or just see if we can help with a technical problem you are having New Zealand RDs – Lukas Svoboda, Jeremy Boyd Australia RDs – Adam Cogan, Peter Stanski

Objectives Discuss history of ASP.NET –Dynamic web content –ASP Present new ASP.NET architecture –.NET core –Compilation –Code behind –Shadow copying Migration from ASP

Dynamic Web Content Dynamic web content has traditionally been generated using CGI, ISAPI, or ASP on Microsoft platforms –The Common Gateway Interface (CGI) provides dynamic content by directly processing requests and issuing responses in a custom process –The Internet Services API provides similar capability through filter DLLs, reducing the overhead –Active Server Pages (ASP) eliminates the need to author DLLs to provide dynamic content -- integrated server-side script generates HTML

ASP Active Server Pages (ASP) simplify common tasks ISAPI DLLs were being used for –ASP was introduced because web developers were building ISAPI extension DLLs to perform things like database queries and posting back HTML –Each different type of request required a new ISAPI extension DLL to be written –ASP.DLL is a generic ISAPI DLL that reads.ASP files, parses and executes server side script blocks, and serves up result

ASP.NET == ASP.NExTversion On one hand, ASP.NET is an evolution of the ASP and is just the next version of ASP –Same intrinsic objects available –Script and html can be mixed –Some ASP code can be ported with no changes –Server-side Javascript is still supported

function Add(x, y) { return x+y; } Test ASP Page 2+2= Row Col0 Row Col1 Written directly to Response "); %> server-side function interspersed server-side script server-side evaluation syntax server-side directive test.asp <%> <%> <%><%> <%> <%> Sample ASP file

Fundamental change ASP.NET is more than just the next version of ASP –Pages are compiled into assemblies improving performance and diagnostics –Code-behind encourages better separation of code from HTML –Extensible, server-side control architecture –Server-side data binding model –Form validation architecture –Web services allow assemblies to expose themselves as SOAP servers

Sample ASP.NET file int Add(int x, int y) { return x+y; } Test ASP.NET Page 2+2= Row Col0 Row Col1 Written directly to Response "); %> server-side function interspersed server-side script server-side evaluation syntax server-side directive test.aspx <%> <%> <%><%> <%> <%>

What is ASP.NET? At a high level, ASP.NET is a collection of.NET classes that collaborate to process an HTTP request and generate an HTTP response –Some classes are loaded from system assemblies –Some classes are loaded from GAC assemblies –Some classes are loaded from local assemblies –To work with ASP.NET, you must build your own classes that integrate into its existing class structure –Some of your classes will be in pre-built assemblies –Some of your classes will be in assemblies generated implicitly from ASP.NET files (aspx, ashx, asmx,...)

High-level view of ASP.NET

Pipeline architecture ASP.NET uses the CLR to replace IIS's ISAPI/ASP architecture –User-defined handler objects used to dispatch HTTP requests –Requests dispatched through ASP.NET-provided ISAPI extension ( aspnet_isapi.dll ) –Handlers run in an ASP.NET-provided worker process ( aspnet_wp.exe in IIS 5, w3wp.exe in IIS 6) –Many IIS features bypassed in favor of ASP.NET- provided features (WAM-based process isolation, ASP object model, and session management)

GET /foo/foo.aspx HTTP/ OK... INETINFO.EXE (IIS 5.0) aspnet_isapi.dll (ISAPI Extension) aspnet_wp.exe (ASP.NET Worker Process) named pipe connection handler IHttpHandler Web Server (Win2000, XP) HttpPipeline architecture (IIS 5.0)

GET /foo/foo.aspx HTTP/ OK... w3wp.exe (ASP.NET Worker Process) handler IHttpHandler Web Server (Win Server 2003) kernel http.sys aspnet_isapi.dll (ISAPI Extension) w3wp.exe (ASP.NET Worker Process) handler IHttpHandler Application Pool #1Application Pool #2 aspnet_isapi.dll (ISAPI Extension) HttpPipeline architecture (IIS 6.0)

Compilation vs. Interpretation When ASP.NET pages are first accessed, they are compiled into assemblies –Subsequent access loads the page directly from the assembly –Eliminates inefficiencies of the scripting model of ASP –No performance difference between compiled components and embedded server-side code –Debugging tools shared with all.NET development –Whenever you author a new.aspx file, you are authoring a new class

Page compilation Every ASP.NET page is compiled into an assembly on first access –The generated assembly contains a single class that derives from System.Web.UI.Page –The generated Page -derived class is the file name of the page, replacing the "." with a "_" (like foo_aspx ) –The generated assembly is stored in the 'Temporary ASP.NET Files' directory on the server machine

ASP.net Page Compilation

ASP.NET basics Each ASP.NET page is parsed and compiled into a class that extends System.Web.UI.Page –Page class implements IHttpHandler –A lot of the Page class is dedicated to forms/control processing –Exposes HttpContext properties as own properties

.aspx Type Information

System.Web.UI.Page The Page class provides facilities for rendering HTML –Response and Request objects are available as properties of the class –Methods for rendering are provided –Events associated with generating the page are defined

class Page : TemplateControl, IHttpHandler { // State management public HttpApplicationState Application {get;} public HttpSessionState Session {virtual get;} public Cache Cache {get;} // Intrinsics public HttpRequest Request {get;} public HttpResponse Response {get;} public HttpServerUtility Server {get;} public string MapPath(string virtualPath); // Client information public string ClientTarget {get; set;} public IPrincipal User {get;} //... } System.Web.UI.Page

class Page : TemplateControl, IHttpHandler { // Core public UserControl LoadControl(string virtualPath); public virtual ControlCollection Controls {get;} public override string ID { get; set;} public bool IsPostBack {get;} protected virtual void RenderControl(HtmlTextWriter writer); // Events public event EventHandler Init; public event EventHandler Load; public event EventHandler PreRender; public event EventHandler Unload; //... } System.Web.UI.Page

Class creation Classes created from.aspx files can be customized –Server-side script blocks are added to the class definition Member variables Member functions –Interspersed script is added to a 'Render' function Executable code

private ArrayList _values = new ArrayList(); private void PopulateArray() { _values.Add("v1"); _values.Add("v2"); _values.Add("v3"); _values.Add("v4"); } aspx==class! <% PopulateArray(); for (int i=0; i<_values.Count; i++) Response.Output.Write(" {0} ", _values[i]); %> member variable declaration member function declaration member function usage member variable usage <% %> Aspx == Class

Server Side Code Placement in Page Compilation

Code behind In addition to customizing the generated Page class using embedded code, ASP.NET supports page inheritance –Technique of Page inheritance is called code- behind –Supported through the Inherits attribute of the Page directive –Promotes separation of code and presentation –Code-behind files can be pre-compiled and placed in a directory named /bin at the top level of the application –Code-behind files can be compiled on demand using the src attribute of the Page directive

Page Language="C#" Inherits="EssentialAspDotNet.Architecture.SamplePage"%> aspx==class! Page Language="C#" Inherits="EssentialAspDotNet.Architecture.SamplePage"%> <%> Sample Page with CodeBehind

namespace EssentialAspDotNet.Architecture { public class SamplePage : Page { private ArrayList _values = new ArrayList(); public SamplePage() { _values.Add("v1"); _values.Add("v2"); _values.Add("v3"); _values.Add("v4"); } protected void WriteArray() { for (int i=0; i<_values.Count; i++) Response.Output.Write(" {0} ", _values[i]); } SamplePage.cs

Class Hierarchy created using code behind

Page Language="C#" src="SampleCodeBehind.cs" Inherits="EssentialAspDotNet.Architecture.SamplePage"%> aspx==class! Page Language="C#" src="SampleCodeBehind.cs" Inherits="EssentialAspDotNet.Architecture.SamplePage"%> <%> Using src attribute to automatically compile code behind

Shadow Copying All assemblies in the /bin directory are shadow copied –Placing assemblies in /bin makes them available to all pages in that application –These assemblies are not referenced directly by ASP.NET –Instead they are copied to an obscure location prior to loading –If the original file ever changes, the file is re-copied –Enables xcopy deployment

Shadow Copy Mechanism

ASP->ASP.NET Migration Several options for migrating 'classic' ASP applications –Run ASP side-by-side with ASP.NET, developing new pages/apps in ASP.NET Quickest path, but session and application state is not shared –Convert existing ASP pages to ASP.NET (but keep using old libraries - ADO and msxml) Access to COM libraries incurs interop boundary crossing –Convert existing ASP pages to ASP.NET with new libraries (ADO.NET and System.XML)

Converting ASP pages to ASP.NET Some pages can be converted by simply renaming to.aspx Most pages will need some 'touch up' –Many directives have been changed (or removed) –VBScript is not directly supported (must be VB.NET) –COM object interaction may require ASPCOMPAT mode –Code block placement different in ASP.NET

Updating directives from ASP- >ASP.NET Several directives in ASP are no longer supported – Instead, use equivalent ASP.NET directives/attributes –

Not VBScript = VB.NET Many language changes mean VBScript code needs to be updated –VB.NET doesn't support default properties objRS("au_fname") => objRS.Fields("au_fname") –IsNull won't work when testing DB results IsNull(dbField) => IsDBNull(dbField) –Let and Set are no longer supported Set obj = CreateObject("xx") => obj = CreateObject("xx")

Not VBScript = VB.NET –Date() is no longer an expression (it is a type) Date() => DateTime.Now –Parameters must be passed within parentheses Response.Write "hi" => Response.Write("hi")

Interacting with COM By default, ASP.NET applications will run in an MTA thread when accessing COM objects through interop –Many classic ASP components are STA-threaded which means that all calls incur a thread-switch –Avoid this by using the AspCompat attribute –

Summary ASP.NET is an evolution of dynamic web page generation techniques All pages in ASP.NET are compiled assemblies Code-behind is a useful technique for separating code logic from presentation Shadow copying enables 'xcopy' deployment Migrating ASP applications typically requires some explicit conversion on your part