+ All Categories
Home > Documents > Chapter 5 - Introduction to ASP.NET

Chapter 5 - Introduction to ASP.NET

Date post: 30-May-2018
Category:
Upload: phannarith
View: 226 times
Download: 0 times
Share this document with a friend

of 46

Transcript
  • 8/9/2019 Chapter 5 - Introduction to ASP.NET

    1/46

    ASP.NET Introduction

    Main Menu 1 of 46

    ASP.NET Introduction

  • 8/9/2019 Chapter 5 - Introduction to ASP.NET

    2/46

    ASP.NET Introduction

    Main Menu 2 of 46

    Objective

    At the end of this chapter, you will be able to

    understand what ASP.NET is and how the ASP &

    ASP.NET pages work.

    Besides, youll be able to understand the advantagesASP.NET provides over ASP.

  • 8/9/2019 Chapter 5 - Introduction to ASP.NET

    3/46

    ASP.NET Introduction

    Main Menu 3 of 46

    Scope

    Introduction to ASP

    Introduction to ASP.NET

    How ASP.NET works

    Advantage of ASP.NET over ASP

    Pre requisite for learning ASP.NET

    Language support

    What is HTTP

    Writing first ASP.NET Page

  • 8/9/2019 Chapter 5 - Introduction to ASP.NET

    4/46

    ASP.NET Introduction

    Main Menu 4 of 46

    Microsoft introduced Active Server Pages in

    December 1996. Microsoft made it available for its

    Internet Information Server (IIS).

    ASP Page is saved with an extension of .asp e.g.test.asp, which is interpreted at the server end.

    ASP code can be written in VBScript or Jscript or

    Perl or any other scripting language provided theserver has a scripting engine available for script.

    Introduction to ASP

  • 8/9/2019 Chapter 5 - Introduction to ASP.NET

    5/46

    ASP.NET Introduction

    Main Menu 5 of 46

    How ASP work

    The working of an ASP page can be well understood

    with following 8 steps.

    A user enters the web site name in the URL using

    his browser.

    Internet then connects to the specified server where the

    Web page resides.

    The requested server is a Windows NT server running the

    IIS.

  • 8/9/2019 Chapter 5 - Introduction to ASP.NET

    6/46

    ASP.NET Introduction

    Main Menu 6 of 46

    How ASP work

    The Web server receives the request, and searches

    for the specified file, which may be an ASP file or a

    HTML file, which contains a HTML form.

    The server then sends this file to the browser, or tothe client, where the user is supposed to fill in the

    form and submit it to the server.

  • 8/9/2019 Chapter 5 - Introduction to ASP.NET

    7/46

    ASP.NET Introduction

    Main Menu 7 of 46

    How ASP work

    User then fills up the form and clicks the SUBMIT

    button on the form, the information in the form is

    sent to the server along with the name of an ASP

    program whose name was embedded into thisHTML file.

    The server gets the requested ASP file along with

    the information in the form and interprets it using

    the ASP.dll

  • 8/9/2019 Chapter 5 - Introduction to ASP.NET

    8/46

    ASP.NET Introduction

    Main Menu 8 of 46

    How ASP work

    If during the processing of ASP it needs some

    information from a database, it connects to the

    database and retrieves the required information from

    it using some COM components like the ActiveXdata objects (ADO)

    The ASP file is processed and the results are

    generated in standard HTML

    This file containing the standard HTML is sent back

    to user where the browser displays the result.

  • 8/9/2019 Chapter 5 - Introduction to ASP.NET

    9/46

    ASP.NET Introduction

    Main Menu 9 of 46

    ASP Objects

    An Object can be defined as something that has

    methods, properties, and collections.

    ASP has the following built-in objects :

    The ScriptingContextObject: It is available

    to the scripting host along with the scripting objects.

    The RequestObject

    The Response Object

    The Application Object

    The Session Object

    The Server Object

  • 8/9/2019 Chapter 5 - Introduction to ASP.NET

    10/46

    ASP.NET Introduction

    Main Menu 10 of 46

    Introduction to ASP.NET

    ASP.NET has been built on common language

    runtime that can be used on a server to build

    powerful web Applications.

    It is a part of emerging Microsoft .NET platform andprovides innovative ways to build and deploy the

    next generation of ASP for use in high performance

    web solutions.

    ASP.NET is largely syntax compatible with ASP.

  • 8/9/2019 Chapter 5 - Introduction to ASP.NET

    11/46

    ASP.NET Introduction

    Main Menu 11 of 46

    How ASP.NET Works

    The working of an ASP page can be well understood

    with following steps. Whole process can be divided

    into 8 steps, which are as follows.

    A user requests for an ASP.NET page in hisbrowser.

    An HTTP request is sent to IIS.

    The xspisapi.dll filters the request and passes therequest to XSP worker process (XSPWP.EXE).

  • 8/9/2019 Chapter 5 - Introduction to ASP.NET

    12/46

    ASP.NET Introduction

    Main Menu 12 of 46

    How ASP.NET Works

    The requested .aspx page (ASP.NET page is saved

    with an extension of .aspx) is read from hard disk or

    cache memory and a new class is generated which

    contains the programming logic of the aspx page.This class is loaded in the memory and executed.

    The server side code generates normal HTML page,

    which is sent back to IIS following the same route.

    IIS sends the page to browser.

  • 8/9/2019 Chapter 5 - Introduction to ASP.NET

    13/46

    ASP.NET Introduction

    Main Menu 13 of 46

    How ASP.NET Works

    Now if the user clicks in the page or after filling

    some information again sends the page back to the

    server.

    The new class handles all the queries sent by theuser. Requests are processed by this class and

    response is prepared.

    Another HTML page is generated after processingthe information sent by the user. This HTML page is

    sent to the user.

  • 8/9/2019 Chapter 5 - Introduction to ASP.NET

    14/46

    ASP.NET Introduction

    Main Menu 14 of 46

    Better Performance

    The ASP.NET page is not read like a new page every

    time.

    An ASP.NET file is compiled only the first time it isaccessed.

    If the page has been sent back then, only modified area is

    read at server. Next request for the same page will use the

    compiled type instance.

    ASP.NET over ASP

  • 8/9/2019 Chapter 5 - Introduction to ASP.NET

    15/46

    ASP.NET Introduction

    Main Menu 15 of 46

    Simplicity

    ASP.NET framework allows you to create a web

    application that cleanly separates application logic from

    presentation code. Also common language runtime simplifies development

    with managed code services like garbage collection,

    debugging facility and automatic reference counting.

    ASP.NET over ASP

  • 8/9/2019 Chapter 5 - Introduction to ASP.NET

    16/46

    ASP.NET Introduction

    Main Menu 16 of 46

    Better tool support

    At the core of ASP.NET is its HTTP runtime (different

    from common language runtime), a high performance

    execution engine for processing HTTP commands. The HTTP runtime is responsible for processing all the

    incoming HTTP requests.

    ASP.NET is support for live updating of applications.

    ASP.NET over ASP

  • 8/9/2019 Chapter 5 - Introduction to ASP.NET

    17/46

    ASP.NET Introduction

    Main Menu 17 of 46

    Language support

    ASP.NET supports all the languages supported by the

    .NET Framework.

    ASP.NET currently offers support for three languages:C#, VB.NET and Jscript.NET.

    ASP.NET over ASP

  • 8/9/2019 Chapter 5 - Introduction to ASP.NET

    18/46

    ASP.NET Introduction

    Main Menu 18 of 46

    Security

    ASP.NET supports HTML forms based authentication.

    ASP.NET works in conjunction with IIS to provide

    authentication and authorization services to applications. As soon as the authentication is done process of

    authorization may start.

    ASP.NET over ASP

    AS d

  • 8/9/2019 Chapter 5 - Introduction to ASP.NET

    19/46

    ASP.NET Introduction

    Main Menu 19 of 46

    Separation of code from html code

    You can separate your programming code from normal

    HTML part.

    This makes easier to create, maintain and modify anyASP.NET page.

    ASP.NET over ASP

    ASP NET I d i

  • 8/9/2019 Chapter 5 - Introduction to ASP.NET

    20/46

    ASP.NET Introduction

    Main Menu 20 of 46

    Less code

    ASP.NET has been enriched with server controls.

    This reduces amount of coding that you need to write.

    All you have to do is to use below mentioned directive: -

    ASP.NET over ASP

    ASP NET I d i

  • 8/9/2019 Chapter 5 - Introduction to ASP.NET

    21/46

    ASP.NET Introduction

    Main Menu 21 of 46

    Caching

    Caching is a technique that is used widely to increase the

    performance by keeping frequently accessed or expensive

    data in memory. ASP.NET offers three types of caching

    Output caching

    Data caching

    Fragment caching

    ASP.NET over ASP

    ASP NET I d i

  • 8/9/2019 Chapter 5 - Introduction to ASP.NET

    22/46

    ASP.NET Introduction

    Main Menu 22 of 46

    ASP.NET has been simplified a lot which makes it

    very easy to learn.

    All you need is knowledge of HTML, internet and a

    language supported in .NET framework.

    You have the option to choose any of three

    languages, presently supported in ASP.NET.

    VB.NET C#

    Jscript

    Pre-Requisite for ASP.NET

    ASP NET I t d ti

  • 8/9/2019 Chapter 5 - Introduction to ASP.NET

    23/46

    ASP.NET Introduction

    Main Menu 23 of 46

    Language Support

    Now let us see how ASP.NET supports these three

    languages.

    All you have to do is declare which language you

    will be using in your ASP.NET page, in thefollowing syntax at the start of your page.

    VB is the default language for ASP.NET

    ASP NET I t d ti

  • 8/9/2019 Chapter 5 - Introduction to ASP.NET

    24/46

    ASP.NET Introduction

    Main Menu 24 of 46

    What is HTTP?

    HTTP (Hyper Text Transfer Protocol) is used for

    transferring the messages between web server and

    web browser.

    HTTP protocol specifies how messages can betransported over the TCP/IP network between web

    server and web browser.

    It specifies the ways in which a browser and Webserver can interact.

    ASP NET I t d ti

  • 8/9/2019 Chapter 5 - Introduction to ASP.NET

    25/46

    ASP.NET Introduction

    Main Menu 25 of 46

    What is HTTP?

    Whenever you retrieve a page from a web site, yourbrowser opens a connection to a web server for thatsite and sends a request.

    The web server receives the request and issues aresponse.

    All communication between a browser and a webserver takes place with the help of request and

    response pair. HTTP protocol is also known as request and

    response protocol.

    ASP NET I t d ti

  • 8/9/2019 Chapter 5 - Introduction to ASP.NET

    26/46

    ASP.NET Introduction

    Main Menu 26 of 46

    A browser request has a certain standard structure.

    A request might also contain a message body or

    entity body.

    Every response begins with the status line, contains

    several headers, and may contain a message body.

    A status line indicates the protocol being used, a

    status code, and a text message.

    What is HTTP?

    ASP NET Introduction

  • 8/9/2019 Chapter 5 - Introduction to ASP.NET

    27/46

    ASP.NET Introduction

    Main Menu 27 of 46

    Configuring IIS 5.0

    To write your first ASP.NET page, first of all create a

    directory.

    Now click on StartProgramsAdministrative ToolsInternet Services Manager

    Now right click on Default Web Site on the left window

    and select New and Virtual Directory

    Writing First ASP.NET Page

    ASP NET Introduction

  • 8/9/2019 Chapter 5 - Introduction to ASP.NET

    28/46

    ASP.NET Introduction

    Main Menu 28 of 46

    Once you click on the Virtual Directory you will

    view the following screen :

    Configuring IIS 5.0

    ASP NET Introduction

  • 8/9/2019 Chapter 5 - Introduction to ASP.NET

    29/46

    ASP.NET Introduction

    Main Menu 29 of 46

    Click on next and type the Alias name i.e. this is the

    name of your default directory.

    Next screen will ask for the existing directory, which

    will contain all the real examples.

    Here you will be giving the name of the directory,

    which was created initially.

    Again click on next and the next screen will tell youthat you have successfully completed the virtual

    directory creation wizard. Click on finish.

    Configuring IIS 5.0

    ASP NET Introduction

  • 8/9/2019 Chapter 5 - Introduction to ASP.NET

    30/46

    ASP.NET Introduction

    Main Menu 30 of 46

    Creating ASP.NET Application

    Open Microsoft Visual Studio .NET.

    In the start page click on New Project button.

    Click on ASP.NET Web Application

    Give a name say Ch1 and specify the location of

    the virtual directory that you created using IIS.

    In the Toolbox, under the Web Forms tab, drag a

    button and drop it on the form.

    ASP NET Introduction

  • 8/9/2019 Chapter 5 - Introduction to ASP.NET

    31/46

    ASP.NET Introduction

    Main Menu 31 of 46

    Creating ASP.NET Application

    Set the ID property of the button to clickBtn

    Set the Text property of the button to Click Me.

    Now double click on the button to open the code

    window which shows the click event of the button.

    Write the following code in it :

    clickBtn.Text= Hello ASP.NET

    ASP NET Introduction

  • 8/9/2019 Chapter 5 - Introduction to ASP.NET

    32/46

    ASP.NET Introduction

    Main Menu 32 of 46

    Creating ASP.NET Application

    Click on the Start button and your application runs

    in the browser and on click of the button, you can

    see the text on the button changing.

    Or

    View the output of your aspx page by opening

    internet explorer and type in the URL

    http://localhost/WebForms/Ch1/WebForm1.asp

    ASP NET Introduction

  • 8/9/2019 Chapter 5 - Introduction to ASP.NET

    33/46

    ASP.NET Introduction

    Main Menu 33 of 46

    You will see the

    followingoutput.

    Creating ASP.NET Application

    ASP NET Introduction

  • 8/9/2019 Chapter 5 - Introduction to ASP.NET

    34/46

    ASP.NET Introduction

    Main Menu 34 of 46

    Configuring Front Page 2002

    The following steps need to be performed in Front

    Page to create a new web site.

    Open Front Page 2002 and click on Menu item File

    New Page or Web. Select the option empty web from the right window.

    ASP NET Introduction

  • 8/9/2019 Chapter 5 - Introduction to ASP.NET

    35/46

    ASP.NET Introduction

    Main Menu 35 of 46

    Configuring Front Page 2002

    A dialog box is displayed, select one page web from

    it and in the location textbox specify a folder in C

    drive say, FrontPageWeb.

    ASP NET Introduction

  • 8/9/2019 Chapter 5 - Introduction to ASP.NET

    36/46

    ASP.NET Introduction

    Main Menu 36 of 46

    Configuring Front Page 2002

    Your web is now created using Front Page.

    Double click on the index page (this is the home

    page of your web site).

    Click on new page button on the toolbar to add a

    new page.

    Save this page with an .aspx extension say,

    one.aspx.

    ASP NET Introduction

  • 8/9/2019 Chapter 5 - Introduction to ASP.NET

    37/46

    ASP.NET Introduction

    Main Menu 37 of 46

    Configuring Front Page 2002

    Go to HTML tab and write the following code

    ASP NET Introduction

  • 8/9/2019 Chapter 5 - Introduction to ASP.NET

    38/46

    ASP.NET Introduction

    Main Menu 38 of 46

    Configuring Front Page 2002

    Add a hyperlink in home page which points to the

    new .aspx page by clicking on Menu Item Insert

    Hyperlink.

    ASP.NET Introduction

  • 8/9/2019 Chapter 5 - Introduction to ASP.NET

    39/46

    ASP.NET Introduction

    Main Menu 39 of 46

    Configuring Front Page 2002

    Now Click on the publish button in the toolbar or go

    to Menu item FilePublish Web.

    Specify the URL of your web site say

    http://localhost/aa and click on PUBLISH Button.

    ASP.NET Introduction

  • 8/9/2019 Chapter 5 - Introduction to ASP.NET

    40/46

    ASP.NET Introduction

    Main Menu 40 of 46

    Configuring Front Page 2002

    Click on the first hyperlink i.e. Click here to view

    your published site to display your web site on the

    Web Browser.

    ASP.NET Introduction

  • 8/9/2019 Chapter 5 - Introduction to ASP.NET

    41/46

    ASP.NET Introduction

    Main Menu 41 of 46

    Configuring Front Page 2002

    Click on the hyperlink on the web page to display

    your .aspx page on the web browser.

    ASP.NET Introduction

  • 8/9/2019 Chapter 5 - Introduction to ASP.NET

    42/46

    ASP.NET Introduction

    Main Menu 42 of 46

    Configuring Front Page 2002

    The Output would be as follows :

    ASP.NET Introduction

  • 8/9/2019 Chapter 5 - Introduction to ASP.NET

    43/46

    Main Menu 43 of 46

    Key points covered in this chapter are:

    ASP lacks in performance as it supports scripting languages

    only. ASP.NET has been introduced by Microsoft under

    .NET framework, to overcome the drawbacks of ASP To understand ASP.NET, you should have knowledge of

    any language supported in .NET Framework and familiarity

    with the environment of Visual Studio.NET.

    ASP.NET provides lots of advantages over ASP e.g.performance, tool support, rich hierarchy, separation of

    code from HTML code, less code, caching etc.

    Summary

    ASP.NET Introduction

  • 8/9/2019 Chapter 5 - Introduction to ASP.NET

    44/46

    Main Menu 44 of 46

    ASP.NET supports three languages at present i.e. VB, C#,

    Jscript.

    HTTP is a protocol, which defines rules to be followed by

    the web browser and server.

    ASP.NET page or the Web Forms can be created from a

    simple notepad or the Visual Studio.NET IDE and even

    from Front Page 2002.

    Configuration of IIS 5.0 Server

    Configuration of Front Page Server extensions.

    Summary

    ASP.NET Introduction

  • 8/9/2019 Chapter 5 - Introduction to ASP.NET

    45/46

    Main Menu 45 of 46

    Self Assessment

    State True or False

    ASP understands only compile type languages.

    ASP.NET has replaced ASP completely.

    ASP.NET is interpreted at the server. ASP supports only 3 objects.

    ASP.NET supports C# and VB.

    ASP.NET supports JavaScript.

    ASP.NET supports caching.

    ASP.NET requires heavy coding from the developer for

    any task.

    ASP.NET Introduction

  • 8/9/2019 Chapter 5 - Introduction to ASP.NET

    46/46

    Fill in the blanks

    Caching is used to save ______________ accessed data at

    the server end. (Frequently / rarely).

    Self Assessment


Recommended