asp.net cls1

Upload: aruntb

Post on 03-Apr-2018

220 views

Category:

Documents


0 download

TRANSCRIPT

  • 7/29/2019 ASP.net Cls1

    1/22

    ASP.NET

    Understanding Web Communications

  • 7/29/2019 ASP.net Cls1

    2/22

    ASP.NET

    Like all client-server applications, web applicationshave two distinct components:

    ClientAlso known as the front-end interface, the webbrowser presents the user interface, accepts user input,and sends data to the server for processing.

    ServerAlso known as the back end, the web server respondsto requests from clients for specific pages. It responds with

    an HTML page that includes instructions for how togenerate the user interface.

  • 7/29/2019 ASP.net Cls1

    3/22

    ASP.NET

    The web browser (the client) and the web server communicateby using Hypertext Transfer Protocol (HTTP), a text-basednetwork protocol assigned to TCP port 80.

    If the server has a certificate, the client and server can useHTTP Secure (HTTPS) to authenticate the server and encryptcommunications.

    HTTPS is assigned to TCP port 443.

  • 7/29/2019 ASP.net Cls1

    4/22

    ASP.NET

    Communications typically follow these steps:

    1.A user enters an address, such as http://www.microsoft.com/into the web browser.

    2. The web browser connects by using HTTP and sends a GETrequest, such as GET/(to retrieve the root page), to the webserver.

    3. The web server processes the requested page. This action

    might cause the server to return static HTML or image files, orit might execute ASP.NET code that performs workflow tasks orconnects to a database.

  • 7/29/2019 ASP.net Cls1

    5/22

    ASP.NET

    4. The web server uses HTTP to send a response back to theweb browser. If the request was processed successfully,the web server returns the HTTP status code 200, along

    with an HTML document. If the server cannot find thepage, it returns

    the code 404. If the user requests an outdated or relocatedpage, the server returns thecode 302 and the new URL sothat the browser can access the correct page. This is

    known as redirection. Several other responses are possibleas well, depending on the particular situation.

  • 7/29/2019 ASP.net Cls1

    6/22

    ASP.NET

    5. The users web browser then processes the response bydisplaying the HTML page (if the code was 200), showing anerror message (if the code was 404), or loading adifferentpage (if the code was 302). Other server responsesare similarly handled by the browser, depending upon theresponse.

    This process is repeated each time the user clicks a button orlink.

  • 7/29/2019 ASP.net Cls1

    7/22

    The Web Servers Role

    The web server provides the content and the web browserdisplays it to the user.When a web server receives a request,some ofthe actions it takes are to:

    1.Verify that the request is structured legitimately.Sometimes, malicious clients send malformed web requeststo compromise web servers. Web servers must be abletodetect this and respond appropriatelyusually by ignoringthe request.

    2. Authenticate itself. If the server has a Secure SocketsLayer (SSL) certificate and the request was made withHTTPS, the web browser uses the certificate to authenticatethe server. The web server will also encrypt all content

    before returning it to the web browser.

  • 7/29/2019 ASP.net Cls1

    8/22

    The Web Servers Role

    3.Authenticate the user. If the content requires authorization,the web server verifies that the user has submitted credentials.If the user has not been authenticated, the web server redirectsthe user to an authentication form.

    4. Authorize the user. After the Web server authenticates theuser, the web server verifies that the user is allowed to accessthe requested content.

    5. Determine how to handle a request. If the web browser

    requested static content or was simply determining whethercached content could still be used, the web server can directlyrespond. If the web browser requested an ASP.NET page, theweb server must forward the request to ASP.NET.

  • 7/29/2019 ASP.net Cls1

    9/22

    The Web Servers Role

    6. Handle errors. If a server cannot process the users request, itprovides error information to the web browser.

    7. Cache output. Web servers can cache output to improve theresponse time of subsequent requests. Web servers also provide

    caching information to web browsers, so browsers know howlong to keep content cached.

    8. Compress output. Before returning a page to a web browser,a web servercan compress the content to reduce the bandwidth

    required.9. Log access. Web servers typically record usage information for

    security and performance-monitoring purposes.

  • 7/29/2019 ASP.net Cls1

    10/22

    The Web Browsers Role

    1. Send requests to the web server. If the user entershttp://www.microsoft.com, the web browser resolves thewww.microsoft.com Domain Name System (DNS) address, usesHTTP to connect to the server, and requests a page.

    2.Authenticate the server. If the server has an SSL certificateand the request was made with HTTPS, the web browser usesthe certificate to authenticate the server and then decrypt futurecommunications.

    3. Process the response. If the server has provided HTML, thebrowser retrieves embedded objects, such as images, videos, oranimations referenced in the HTML. If the server has providedan error, redirection, or other response, the browser respondsappropriately.

  • 7/29/2019 ASP.net Cls1

    11/22

    The Web Browsers Role

    4. Display HTML and embedded objects. Web browsers useHTML standards to determine how to display a webpage to theuser. Because HTML can contain embedded objects,a webbrowser might have to display dozens of objects to render a

    single webpage.5. Run client scripts. Client scripts, such as those written in

    JavaScript, enable interactive and responsive pages withoutreloading the page.

  • 7/29/2019 ASP.net Cls1

    12/22

    Understanding the Role of HTTP

    HTTP is a text-based communication protocol that is used torequest webpages from a web server and send responses backto a web browser.

    When a webpage is requested, the browser sends a request to the

    web server.

    The request might look like the following.

    GET /default.aspx HTTP/1.1

    Host: www.northwindtraders.com

  • 7/29/2019 ASP.net Cls1

    13/22

    Common HTTP/1.1 Methods

    HTTP METHOD DESCRIPTION

    GET Gets an object, such as awebpage, from the server. AGET request for a specific URL

    (Uniform Resource Locator)retrieves the resource.Forexample, GET /test.htmretrieves the test.htm resource(typically a static file, but it

    could be generateddynamically).

  • 7/29/2019 ASP.net Cls1

    14/22

    Common HTTP/1.1 Methods

    HTTP METHOD DESCRIPTION

    POST Sends data to the web serverfor processing. This is typicallywhat happens when users enter

    data on a form and submit thatdata as part of their request,but it has other meanings whenused outside the bounds ofHTML forms.

  • 7/29/2019 ASP.net Cls1

    15/22

    Common HTTP/1.1 Methods

    HTTP METHOD DESCRIPTION

    HEAD Retrieves the meta informationfor an object withoutdownloading the page itself.

    HEAD is typically used to verifythat a resource hasnt changedsince the browser cached it.

  • 7/29/2019 ASP.net Cls1

    16/22

    Common HTTP/1.1 Methods

    Row 1 Row 2 Row 3 Row 4

    0

    2

    4

    6

    8

    10

    12

    Column 1

    Column 2

    Column 3

    HTTP METHOD DESCRIPTION

    PUT Allows a client to directly createa resource at the indicated URLon the server. If the user has

    permission, the server takes thebody of the request, creates thefile specified in the URL, andcopies the received data to thenewly created file.

  • 7/29/2019 ASP.net Cls1

    17/22

    Status Code Groups

    SStatus Code Groups DESCRIPTION1xx Informational: The request was received,

    and the server is continuing to process.

    2xx Success: The action was successfully

    received, understood, and accepted.

    3xx Redirect Command: The client must accessa different resource instead.

    4xx Client Error: The request has a syntaxerror or the server does not knowhow tofulfill the request.

    5xxServer Error: The server failed to fulfill arequest that appears to be valid.

  • 7/29/2019 ASP.net Cls1

    18/22

    What is ASP.NET

    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

  • 7/29/2019 ASP.net Cls1

    19/22

    What is ASP.NET File

    An ASP.NET file is just the same as an HTML file

    An ASP.NET file can contain HTML, XML, and scripts

    Scripts in an ASP.NET file are executed on the server

    An ASP.NET file has the file extension ".aspx"

  • 7/29/2019 ASP.net Cls1

    20/22

    How ASP.NET Works

    When a browser requests an HTML file, the server returns the file

    When a browser requests an ASP.NET file, IIS passes the requestto the ASP.NET engine on the server

    The ASP.NET engine reads the file, line by line, and executes thescripts in the file

    Finally, the ASP.NET file is returned to the browser as plain HTML

  • 7/29/2019 ASP.net Cls1

    21/22

    ASP.NET Framework

  • 7/29/2019 ASP.net Cls1

    22/22

    CLR