ASP 'NET - PowerPoint PPT Presentation

1 / 24
About This Presentation
Title:

ASP 'NET

Description:

Takes advantage of HTTP commands and policies to set up two-way, browser-to ... ETag: 'd02acf81975cc11:a78' Content-Length: 46 [blank line] html body Hello, world ... – PowerPoint PPT presentation

Number of Views:51
Avg rating:3.0/5.0
Slides: 25
Provided by: csl73
Category:
Tags: asp | net | etag

less

Transcript and Presenter's Notes

Title: ASP 'NET


1
  • ASP .NET

2
ASP.NET
  • ASP.NET works on top of the HTTP protocol
  • Takes advantage of HTTP commands and policies to
    set up two-way, browser-to-server communication
    and cooperation
  • Web Forms model the event-driven model of
    interaction finally comes to the Web

3
Event-Driven Programming over HTTP
  • Implementing an event model over the Web requires
    any data related to the client-side user's
    activity to be forwarded to the server for
    corresponding and stateful processing
  • The server needs to process the output of client
    actions and trigger reactions while being aware
    of the overall state of the application

4
States
  • The state of the application contains two types
    of information the state of the client and the
    state of the session
  • The state of the client is easily accessible
    through the syntax and the implementation of the
    ltformgt HTML element. But what about the overall
    state of the session?
  • A reentrant form is an HTML ltformgt element that
    posts to the same page that contains it

5
Web Forms
  • A WebForm consists of two components the user
    interface (UI) and the programming (application)
    logic
  • The user interface is the visual component of a
    WebForm it consists of HTML and controls
    specific to the Web application
  • The programming logic of a Web application in
    ASP.NET is contained in a separate file that
    contains the code to handle the user's
    interaction with the form

6
HTTP
  • Defines how web browsers and web servers
    communicate with each other
  • Typically transmitted over TCP
  • HTML
  • lthtmlgt
  • ltbodygt
  • Hello, world
  • lt/bodygt
  • lt/htmlgt

7
HTTP Request
  • GET /simple.html HTTP/1.1
  • Accept /
  • Accept-Language en-us
  • Accept-Encoding gzip, deflate
  • If-Modified-Since Wed, 24 Oct 2001 141236 GMT
  • If-None-Match "50b0d3ee955cc11a78"
  • User-Agent Mozilla/4.0.(compatible MSIE.6.0
    Windows NT 5.1)
  • Host www.wintellect.com
  • Connection Keep-Alive
  • blank line

8
HTTP Response
  • HTTP/1.1 200 OK
  • Server Microsoft-IIS/5.0
  • Date Wed, 24 Oct 2001 141237 GMT
  • Content-Type text/html
  • Accept-Ranges bytes
  • Last-Modified Wed, 24 Oct 2001 140053 GMT
  • ETag "d02acf81975cc11a78"
  • Content-Length 46
  • blank line
  • lthtmlgt
  • ltbodygt
  • Hello, world
  • lt/bodygt
  • lt/htmlgt

9
HTML Forms
  • Forms add user input capabilities to static HTML
    files
  • Appears between ltformgt and lt/formgt tags
  • lthtmlgt
  • ltbodygt
  • ltformgt
  • ltinput type"text" name"op1" /gt
  • ltinput type"text" name"op2" /gt
  • ltinput type"submit" value" " /gt
  • lt/formgt
  • lt/bodygt
  • lt/htmlgt

10
Submit Buttons
  • ltinput typesubmitgt
  • When clicked, it submits the form to a Web server
  • The browser submits the form along with any input
    in the forms controls
  • GET
  • POST

11
GET
  • GET /calc.html?op12op22 HTTP/1.1
  • .
  • .
  • .
  • Connection Keep-Alive
  • blank line

12
POST
  • Rather than transmit user input in the URL, with
    a POST command the browser passes it in the body
    of the HTTP request
  • POST /calc.html HTTP/1.1
  • .
  • .
  • .
  • Content-Type application/x-www-form-urlencoded
  • Content-Length 11
  • blank line
  • op12op22

13
Postback
  • Regardless of whether a GET or a POST command is
    used, when input from an HTML form is submitted
    back to the server, we say that a postback has
    occurred

14
Server-Side Processing
  • How do we go from the previous HTML page to this
    one
  • lthtmlgt
  • ltbodygt
  • ltformgt
  • ltinput type"text" name"op1" value"2" /gt
  • ltinput type"text" name"op2" value"2" /gt
  • ltinput type"submit" value" " /gt
  • 4
  • lt/formgt
  • lt/bodygt
  • lt/htmlgt

15
Solution 1
  • Use Common Gateway Interface (CGI)
  • Applications that use it are typically written in
    Perl
  • CGI applications read the input accompanying
    postbacks through server environment variables
    and standard input (stdin), and they write HTTP
    responses to standard output (stdout)

16
Solution 2
  • ISAPI extension DLL
  • Internet Server Application Programming Interface
  • ISAPI extensions are Windows DLLs that are hosted
    by Internet Information Services
  • IIS forwards HTTP requests to an ISAPI DLL by
    calling a special function exported from the DLL
  • The DLL generates HTTP responses

17
Solution 3
  • The Active Server Pages Solution
  • Active Server Pages lower the barrier to entry
    for Web developers by allowing HTML and
    server-side script to be freely mixed in ASP
    files
  • Scripts are written in JScript or VBScript

18
ASP
  • Active Server Pages lower the barrier to entry
    for Web developers by allowing HTML and
    server-side script to be freely mixed in ASP
    files

19
ASP
  • lt_at_ Language"VBScript" gt
  • lthtmlgt
  • ltbodygt
  • ltformgt
  • ltinput type"text" name"op1" value"lt
    Request ("op1") gt"/gt
  • ltinput type"text" name"op2" value"lt
    Request ("op2") gt" /gt
  • ltinput type"submit" value" " /gt
  • lt
  • If Request ("op1") ltgt "" And Request
    ("op2") ltgt "" Then
  • a CInt (Request ("op1"))
  • b CInt (Request ("op2"))
  • Response.Write (CStr (a b))
  • End If
  • gt
  • lt/formgt
  • lt/bodygt
  • lt/htmlgt

20
ASP
  • Whats wrong with ASP?
  • Its slow
  • Why?
  • Interpreted rather than compiled
  • Lacks encapsulation

21
ASP.NET Web Forms
  • Web forms bring object-oriented programming to
    the Web
  • Combine ASPs ease of use with the speed of
    compiled code

22
ASP.NET Web Forms
  • lthtmlgt
  • ltbodygt
  • ltform runat"server"gt
  • ltaspTextBox ID"op1" RunAt"server" /gt
  • ltaspTextBox ID"op2" RunAt"server" /gt
  • ltaspButton Text" " OnClick"OnAdd"
    RunAt"server" /gt
  • ltaspLabel ID"Sum" RunAt"server" /gt
  • lt/formgt
  • lt/bodygt
  • lt/htmlgt
  • ltscript language"C" runat"server"gt
  • void OnAdd (Object sender, EventArgs e)
  • int a Convert.ToInt32 (op1.Text)
  • int b Convert.ToInt32 (op2.Text)
  • Sum.Text (a b).ToString ()
  • lt/scriptgt

23
Generated HTML
  • lthtmlgt
  • ltbodygt
  • ltform name"_ctl0" method"post"
    action"calc.aspx" id"_ctl0"gt
  • ltinput type"hidden" name"__VIEWSTATE"
    value"dDwxOTE0NDY4ODE2Ozs" /gt
  • ltinput name"op1" type"text" id"op1" /gt
  • ltinput name"op2" type"text" id"op2" /gt
  • ltinput type"submit" name"_ctl1" value"
    " /gt
  • ltspan id"Sum"gtlt/spangt
  • lt/formgt
  • lt/bodygt
  • lt/htmlgt

24
Summary
  • Completed pages 177-193
Write a Comment
User Comments (0)
About PowerShow.com