ASP.NET

32
ASP.NET Reuven Abliyev Elyahu Sivaks Ariel Daliot

description

ASP.NET. Reuven Abliyev Elyahu Sivaks Ariel Daliot. What is ASP.NET?. Microsoft’s web page: “Framework for writing dynamic, high-performance Web applications” O’Reilly Nutshell: - PowerPoint PPT Presentation

Transcript of ASP.NET

Page 1: ASP.NET

ASP.NET

Reuven Abliyev

Elyahu Sivaks

Ariel Daliot

Page 2: ASP.NET

What is ASP.NET?

Microsoft’s web page:

“Framework for writing dynamic, high-performance Web applications”

O’Reilly Nutshell:

“Programming framework built on the common language runtime that can be used on a web server to build powerful Web applications”

In other words:“Great web pages in a short time, less code”

Page 3: ASP.NET

Why ASP.NET? 10 years of evolution in 10 slides

Why ASPnotNET?Why HTML?

Page 4: ASP.NET

HTML – HyperText Markup Language

Commands denote certain text as headings, paragraphs, lists, text format, fonts, links, etc.

HTML is static – i.e. pages cannot change on the request of the user, must be changed explicitly

Page 5: ASP.NET

HTML Example<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html><head>

<title>Seminar in Software Design - 2005/6</title><link href="style.css" type="text/css" rel="stylesheet">

<style>.detailprop {

font-size: 12pt;font-weight: bold;color: #003366;

} </style></head><body><!-- large frame --><table cellpadding="0" cellspacing="0" width="100%" border="0"><tr><td style="padding-right:20px;"><!-- /large frame --><table id="headerTable" cellpadding="0" cellspacing="0"><tr><table id="content" cellpadding="0" cellspacing="0" width="100%" border="0"><tr><td valign="top" width="150" style="padding-right:15px;"><!-- Side menu--><table id="sidemenu" class="borderedtable" cellpadding="0" cellspacing="0" width="140"><tr> <td class="sidemenuitem" width="134"> <p align="center"><a href="index.html" ><font size="2" color="#000080"> Information</font></a></td></tr><td class="sidemenuitem" width="134" align="center"><a href="schedule.html" > Schedule</a></td></tr><tr> <td class="sidemenuitem" width="134" align="center"><a href="guidelines.html"> Guidelines</a></td></tr>

Page 6: ASP.NET

How do web pages work - HTTP

Suppose user enters URL www.cs.huji.ac.il/~ssd

1a. HTTP client initiates TCP connection to HTTP server (process) at www.cs.huji.ac.il on port 80

2. HTTP client sends HTTP request message (containing GET command) into TCP connection socket. Message indicates that client wants object ~ssd/index.htm

1b. HTTP server at host www.cs.huji.ac.il waiting for TCP connection at port 80. “accepts” connection, notifying client

3. HTTP server receives request message, forms aresponse message containing html, and sends message into its socket

time

(contains text, references to 10

jpeg images)

Page 7: ASP.NET

HTTP (cont.)

5. HTTP client receives response message containing html file, displays html. Parsing html file, finds 10 referenced jpeg objects

6. Steps 1-5 repeated for each of 10 jpeg objects

4. HTTP server closes TCP connection.

time

7. Client can return request message with POST command holding form input

Page 8: ASP.NET

HTTP request message

two types of HTTP messages: request, response HTTP request message:

ASCII (human-readable format)

GET /somedir/page.html HTTP/1.1Host: www.someschool.edu User-agent: Mozilla/4.0Connection: close Accept-language:fr

(extra carriage return, line feed)

request line(GET, POST,

HEAD commands)

header lines

Carriage return, line feed

indicates end of message

Page 9: ASP.NET

HTTP response message

HTTP/1.1 200 OK Connection closeDate: Thu, 06 Aug 1998 12:00:15 GMT Server: Apache/1.3.0 (Unix) Last-Modified: Mon, 22 Jun 1998 …... Content-Length: 6821 Content-Type: text/html data data data data data ...

status line(protocol

status codestatus phrase)

header lines

data, e.g., requestedHTML file

Page 10: ASP.NET

DHTML- Dynamic HTML

Enables adding high-level logic in the HTML page in the form of javascript functions

Scripts run client-sideCompeting techniques include

Macromedia Flash (for animation) and applets

Most recent HTML technology is XHTML

Page 11: ASP.NET

DHTML Example

<html> <head><title>Test</title> <style type="text/css"> h2 {background-color: lightblue; width: 100%} a {font-size: larger; background-color: goldenrod} a:hover {background-color: gold} #example1 {display: none; margin: 3%; padding: 4%; background-color: limegreen} </style> <script type="text/javascript"> <!–

function changeDisplayState (id) { e=document.getElementById(id)

if (e.style.display == 'none' || e.style.display =="") { e.style.display = 'block' this.innerHTML = 'Hide example'}

else { e.style.display = 'none' this.innerHTML = 'Show example'} } //

--> </script> </head> <body>

Page 12: ASP.NET

Server-side dynamic web page technologies

CGI – Common Gateway Interface (~1993): Enables a client web browser to request data from a

program executed on the web server Client doesn’t need to know much more than HTML Each page is actually a *.cgi text file with script

commands (typically perl but can be any language) An instance of the code interpreter is executed for every

CGI request! Parameters are passed through the URL Example:

http://cs.huji.ac.il/~ssd/test.cgi?p1=val1&p2=val2

Page 13: ASP.NET

CGI Example in C

/*********************************************************************** **/ /**

**/ /** hello_s.cgi: simple "hello, world", to demonstrate basic CGI output. **/ /**

**//*********************************************************************** **/ #include <stdio.h> void main() { /** Print the CGI response header, required for all HTML output. **/ /** Note the extra \n, to send the blank line. **/

printf("Content-type: text/html\n\n") ;

/** Print the HTML response page to STDOUT. **/ printf("<html>\n") ; printf("<head><title>CGI Output</title></head>\n") ; printf("<body>\n") ; printf("<h1>Hello, world.</h1>\n") ; printf("</body>\n") ; printf("</html>\n") ; exit(0) ; }

Page 14: ASP.NET

ASPnotNET…Active Server Pages

Microsoft’s server-side technology for dynamically-generated web pages

Marketed in 1996 as an add-on to Internet Information Services (IIS)

Mixes server-side code with client-side HTML Code executed by the server’s ASP engine Example: (pages have *.asp extensions)

http://cs.huji.ac.il/~ssd/test.asp?p1=val1&p2=val2

Page 15: ASP.NET

ASP Example

<html>

<body>

This page is executed on date <% response.write(date()) %> and time <% response.write(time()) %> .

</body>

</html>

----------------------------

This page is executed on date 17.11-2005 and time 10:00.

Page 16: ASP.NET

ASPnotNet

The code between the <% ... %> delimiters is processed by the server

Programming ASP is made easier by various objects that correspond to a group of frequently-used functionalities useful for creating dynamic web pages

Six such built-in objects: Application, ASPError, Request, Response, Server and Session

Page 17: ASP.NET

Disadvantages of ASPnotNet

The code is cumbersome to write and read Code can only be written in Jscript or VBscript Code is interpreted and not compiled The “<%” directive causes the interpreter to be

loaded every time at the server No separation between the graphical aspects

of the page and the programmatic ones Difficult to program the page controls

Page 18: ASP.NET

ASP.NET – Fixes the previous points (2001)

Complete separation between code and HTML Code uses the .NET framework with all its advantages

Supports any language that can use the .NET framework (C#, J#, VB.NET, Perl.NET, C++, etc…)

Code is compiled and thus much more efficient Pages have the*.aspx extensions Enhanced security: User authentication, with accounts

and roles Very easy to design pages using drag-n-drop Controls are easily programmed Very easy deployment, no need to register dlls Can benefit from the advantages of Visual Studio

Page 19: ASP.NET

“Complete separation between code and HTML”

Page 20: ASP.NET
Page 21: ASP.NET
Page 22: ASP.NET
Page 23: ASP.NET

GUI Controls

There are server-side controls (code-behind, rich features, easy to change, validation)

Client-side controls (html, no code-behind…) User-defined controls (customized)

Page 24: ASP.NET

Server-control validation example

Page 25: ASP.NET

The .NET framework

Collection of over 4500 classes for rich functionalities: Data streaming, GUI, XML, Data access, Networking, Security, etc…(whatever you have in JAVA)

These classes are called the .NET Framework Class Library (FCL)

Has a platform independent language: MSIL – MS Intermediate Language

There are about 25 languages that have compilers to IL The language compiler compiles the code to IL Common Language Runtime (CLR) is the execution environment

for code written for the .NET Framework The CLR does the compilation of the IL code to the native code

Page 26: ASP.NET

How a .NET program is compiled

Page 27: ASP.NET

The .NET framework (cont.)

The CLR manages the execution of .NET code, including:

memory allocation garbage collection (which helps avoid memory

leaks) security (including applying differing trust

levels to code from different sources) thread management enforcing type-safety

Page 28: ASP.NET

ASP.NET page life-cycle:

Browser request an ASP.NET page

ASP.NET engine checks for changes in the IL code for the requested page

changed

CLR compiles IL to executable

not changed

Recompilation of code, new IL

Execution => HTML sent back

Page 29: ASP.NET

Performance (from www.microsoft.com)

Microsoft .NET Outperforms J2EE: Similar functionality uses 1/4th lines of code Executes 28x faster Supports 7.6x as many concurrent usersWith only 1/6th processor utilization

Applications that migrated from classic ASP see a 3x to 5x increase in pages served

Page 30: ASP.NET

What's behind it

Compiled execution  Dynamic compilation. ASP.NET will

automatically detect any changes and dynamically compile the files

Page output cached on serverMemory Leak, DeadLock and Crash

Protection Web-Farm Session State

Page 31: ASP.NET

Security

Authentication – verifying who you areAuthorization – verifying what you are

allowed to doASP.NET provides three built-in options

for authentication: Windows authenticationForms authenticationPassport authentication

Page 32: ASP.NET