320 likes | 457 Views
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:
E N D
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: “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”
Why ASP.NET? 10 years of evolution in 10 slides • Why ASPnotNET? • Why HTML?
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
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>
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 How do web pages work - HTTP (contains text, references to 10 jpeg images) 1b. HTTP server at host www.cs.huji.ac.ilwaiting for TCP connection at port 80. “accepts” connection, notifying client 2. HTTP client sends HTTP request message (containing GET command) into TCP connection socket. Message indicates that client wants object ~ssd/index.htm 3. HTTP server receives request message, forms aresponse message containing html, and sends message into its socket time
5. HTTP client receives response message containing html file, displays html. Parsing html file, finds 10 referenced jpeg objects HTTP (cont.) 4. HTTP server closes TCP connection. time 6.Steps 1-5 repeated for each of 10 jpeg objects 7.Client can return request message with POST command holding form input
HTTP request message • two types of HTTP messages: request, response • HTTP request message: • ASCII (human-readable format) request line (GET, POST, HEAD commands) GET /somedir/page.html HTTP/1.1 Host: www.someschool.edu User-agent: Mozilla/4.0 Connection: close Accept-language:fr (extra carriage return, line feed) header lines Carriage return, line feed indicates end of message
HTTP response message status line (protocol status code status phrase) HTTP/1.1 200 OK Connection close Date: 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 ... header lines data, e.g., requested HTML file
DHTML- Dynamic HTML • Enables adding high-level logic in the HTML page in the form of javascript functions • Scripts run client-side • Competing techniques include Macromedia Flash (for animation) and applets • Most recent HTML technology is XHTML
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>
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
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) ; }
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
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.
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
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
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*.aspxextensions • 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
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)
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
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
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 not changed Recompilation of code, new IL CLR compiles IL to executable Execution => HTML sent back
Performance (fromwww.microsoft.com) • Microsoft .NET Outperforms J2EE: • Similar functionality uses 1/4th lines of code • Executes 28x faster • Supports 7.6x as many concurrent users • With only 1/6th processor utilization • Applications that migrated from classic ASP see a 3x to 5x increase in pages served
What's behind it • Compiled execution • Dynamic compilation. ASP.NET will automatically detect any changes and dynamically compile the files • Page output cached on server • Memory Leak, DeadLock and Crash Protection • Web-Farm Session State
Security • Authentication – verifying who you are • Authorization – verifying what you are allowed to do • ASP.NET provides three built-in options for authentication: • Windows authentication • Forms authentication • Passport authentication