18
Introduction to ASP.NET Mohammad Jawad 1 What is ASP.NET? How it works? Architecture of ASP.NET

Introduction to ASP · Introduction to ASP.NET ... Global.asax. What is ASP.Net 3 ASP.NET is a server side scripting technology that enables scripts (embedded in web pages) to be

  • Upload
    others

  • View
    11

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Introduction to ASP · Introduction to ASP.NET ... Global.asax. What is ASP.Net 3 ASP.NET is a server side scripting technology that enables scripts (embedded in web pages) to be

Introduction to ASP.NET

Mohammad Jawad

1

What is ASP.NET? How it works?Architecture of ASP.NET

Page 2: Introduction to ASP · Introduction to ASP.NET ... Global.asax. What is ASP.Net 3 ASP.NET is a server side scripting technology that enables scripts (embedded in web pages) to be

Table of Contents2

Introduction to ASP.NET

What is ASP.Net

History of ASP.NET

ASP.NET Architecture Overview

Separation of Presentation from Logic

ASP.NET Base Components

Web Controls

Web Forms

Web.Config

Global.asax

Page 3: Introduction to ASP · Introduction to ASP.NET ... Global.asax. What is ASP.Net 3 ASP.NET is a server side scripting technology that enables scripts (embedded in web pages) to be

What is ASP.Net3

ASP.NET is a server side scripting technology that enables scripts

(embedded in web pages) to be executed by an Internet server.

ASP.NET is a Microsoft Technology

ASP stands for Active Server Pages

ASP.NET is a program that runs inside IIS

IIS (Internet Information Services) is Microsoft's Internet server

IIS comes as a free component with Windows servers

IIS is also a part of Windows 2000 , XP, Vista, 7,8 and 10

Page 4: Introduction to ASP · Introduction to ASP.NET ... Global.asax. What is ASP.Net 3 ASP.NET is a server side scripting technology that enables scripts (embedded in web pages) to be

History of ASP.Net4

At the beginning of Internet (up to 1997)

CGI, ISAPI – C, C++

Classic ASP (1997-2002)

Based on VB Script, COM, ADO

ASP.NET 1.0 / 1.1 (2002-2005)

The First .NET based Web Development API

ASP.NET 2.0 (2005-2007) – based on .NET 2.0

ASP.NET 3.5 (2007-2009) – LINQ to SQL

ASP.NET 4.0 (2010)

ASP.NET 4.5 (2012

Page 5: Introduction to ASP · Introduction to ASP.NET ... Global.asax. What is ASP.Net 3 ASP.NET is a server side scripting technology that enables scripts (embedded in web pages) to be

.NET Framework component stack

.NET Framework (pronounced dot net) is a:

software framework developed by

Microsoft that runs primarily on Microsoft

Windows.

It includes a large class library known as

Framework Class Library (FCL) and provides

language interoperability across several

programming languages.

Programs written for .NET Framework

execute in a software environment known as

Common Language Runtime (CLR)

5

Page 6: Introduction to ASP · Introduction to ASP.NET ... Global.asax. What is ASP.Net 3 ASP.NET is a server side scripting technology that enables scripts (embedded in web pages) to be

Versionnumber

CLRversion

Releasedate

Development tool

Included in

Windows Windows Server

1.0 1.0 2002-02-13Visual Studio .NET[22] XP[a] N/A

1.1 1.1 2003-04-24Visual Studio .NET 2003[22] N/A 2003

2.0 2.0 2005-11-07Visual Studio 2005[24] N/A

2003, 2003 R2,[25]

2008 SP2, 2008 R2 SP1

3.0 2.0 2006-11-06Expression Blend[26][b] Vista

2008 SP2, 2008 R2 SP1

3.5 2.0 2007-11-19Visual Studio 2008[27] 7, 8[c], 8.1[c], 10[c] 2008 R2 SP1

4.0 4 2010-04-12Visual Studio 2010[28] N/A N/A

4.5 4 2012-08-15Visual Studio 2012[29] 8 2012

4.5.1 4 2013-10-17Visual Studio 2013[30] 8.1 2012 R2

4.5.2 4 2014-05-05 N/A N/A N/A

4.6 4 2015-07-20Visual Studio 2015[31] 10 N/A

4.6.1 4 2015-11-30[32] Visual Studio 2015 Update 1

10 v1511 N/A

4.6.2 4 2016-08-02[33] 10 v1607 N/A

Page 7: Introduction to ASP · Introduction to ASP.NET ... Global.asax. What is ASP.Net 3 ASP.NET is a server side scripting technology that enables scripts (embedded in web pages) to be

ASP.NET Execution7

ASP.NET applications are executed via a sequence of HTTP

requests and HTTP responses

Client Web browser request ASPX pages

The Web server executes the ASPX page and produce

XHTML + CSS + JavaScript

Page 8: Introduction to ASP · Introduction to ASP.NET ... Global.asax. What is ASP.Net 3 ASP.NET is a server side scripting technology that enables scripts (embedded in web pages) to be

ASP.NET Architecture8

Windows Server

Internet Information Server (IIS) ISAPI Filters (aspnet_isapi.dll)

ASP.NET runtime (aspnet_wp.dll / w3wp.dll)

XML-based configuration

HttpApplication Cache

HttpModules

Session state Authentication …

HttpHandlers

ASP.NET pages ASP.NET Web services …

Html Controls AJAX

Web controls User controls …

Page 9: Introduction to ASP · Introduction to ASP.NET ... Global.asax. What is ASP.Net 3 ASP.NET is a server side scripting technology that enables scripts (embedded in web pages) to be

ASP.NET: How it Works?9

Traditional Web pages (static HTML)

Consist of static HTML, images, styles, etc.

Execute code on the client side

Simple operations

ASP.NET Web Forms

Execute code on the server side

Database access

Dynamic pages

Higher security level

Page 10: Introduction to ASP · Introduction to ASP.NET ... Global.asax. What is ASP.Net 3 ASP.NET is a server side scripting technology that enables scripts (embedded in web pages) to be

Separate Visualization from Business Logic

10

Traditional Web development keep HTML and

programming code in one file (PHP, ASP, …)

Hard to read, understand and maintain

Hard to test and debug

ASP.NET splits the Web pages into two parts:

.aspx file containing HTML for visualization

"Code behind" files (.cs for C#) containing

presentation logic for particular page

Page 11: Introduction to ASP · Introduction to ASP.NET ... Global.asax. What is ASP.Net 3 ASP.NET is a server side scripting technology that enables scripts (embedded in web pages) to be

Separate Visualization from Business Logic

11

Page 12: Introduction to ASP · Introduction to ASP.NET ... Global.asax. What is ASP.Net 3 ASP.NET is a server side scripting technology that enables scripts (embedded in web pages) to be

Separate Visualization from Business Logic (2)

12

Class generated from the .aspx

file does not derives directly from

Page class

Derives from class defined in the

"code behind", where it is easy to

add methods, event handlers, etc.

Using "code behind" separates

the presentation logic from UI

visualization

System.Web.UI.Page

TestForm.aspx.cs

TestForm.aspx

Page 13: Introduction to ASP · Introduction to ASP.NET ... Global.asax. What is ASP.Net 3 ASP.NET is a server side scripting technology that enables scripts (embedded in web pages) to be

ASP.NET Base Components13

Web Forms – deliver ASP.NET user interface

Web Control – the smallest part we can use in our Web

application (e.g. text box)

"Code behind" – contains the server-side code

Web.config – contains ASP.NET application configuration

Global.asax – class containing application level event

handlers

Page 14: Introduction to ASP · Introduction to ASP.NET ... Global.asax. What is ASP.Net 3 ASP.NET is a server side scripting technology that enables scripts (embedded in web pages) to be

ASP.NET Web Controls14

ASP.NET Web controls are the smallest

component part

Deliver fast and easy component-oriented

development process

HTML abstraction, but finally everything is

HTML

<form runat="server" ID="frmMain"><asp:button runat="server" ID="btn"

Text="Click me!" OnClick="btn_Click" /></form>

Page 15: Introduction to ASP · Introduction to ASP.NET ... Global.asax. What is ASP.Net 3 ASP.NET is a server side scripting technology that enables scripts (embedded in web pages) to be

Web.config15

Main settings and configuration file for ASP.NET

Text based XML document

Defines:

Connection strings to any DB used by app

The default language for child pages

Whether debugging is allowed

<?xml version="1.0" encoding="utf-8" ?><configuration>

<system.web></system.web>

</configuration>

Page 16: Introduction to ASP · Introduction to ASP.NET ... Global.asax. What is ASP.Net 3 ASP.NET is a server side scripting technology that enables scripts (embedded in web pages) to be

Global.asax16

Also known as ASP.NET application file

Located in the Web application root folder

Exposes application and session level events

Application_Start

Application_End

Session_Start

Session_End

Page 17: Introduction to ASP · Introduction to ASP.NET ... Global.asax. What is ASP.Net 3 ASP.NET is a server side scripting technology that enables scripts (embedded in web pages) to be

ASP.NET Execution Model17

First call to particular page

/info/regesstepp/index.html

Page 18: Introduction to ASP · Introduction to ASP.NET ... Global.asax. What is ASP.Net 3 ASP.NET is a server side scripting technology that enables scripts (embedded in web pages) to be

ASP.NET Execution Model (2)

Any other call after the first

18