ASP.
NET Introduction
[Link] Introduction
Main Menu 1 of 46
[Link] Introduction
Objective
At the end of this chapter, you will be able to
understand what [Link] is and how the ASP &
[Link] pages work.
Besides, you’ll be able to understand the advantages
[Link] provides over ASP.
Main Menu 2 of 46
[Link] Introduction
Scope
Introduction to ASP
Introduction to [Link]
How [Link] works
Advantage of [Link] over ASP
Pre requisite for learning [Link]
Language support
What is HTTP
Writing first [Link] Page
Main Menu 3 of 46
[Link] Introduction
Introduction to ASP
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.
“[Link]”, which is interpreted at the server end.
ASP code can be written in VBScript or Jscript or
Perl or any other scripting language provided the
server has a scripting engine available for script.
Main Menu 4 of 46
[Link] Introduction
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.
Main Menu 5 of 46
[Link] Introduction
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 to
the client, where the user is supposed to fill in the
form and submit it to the server.
Main Menu 6 of 46
[Link] Introduction
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 this
HTML file.
The server gets the requested ASP file along with
the information in the form and interprets it using
the [Link]
Main Menu 7 of 46
[Link] Introduction
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 ActiveX
data 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.
Main Menu 8 of 46
[Link] Introduction
ASP Objects
An Object can be defined as something that has
methods, properties, and collections.
ASP has the following built-in objects :
The ScriptingContext Object: It is available
to the scripting host along with the scripting objects.
• The Request Object
• The Response Object
• The Application Object
• The Session Object
• The Server Object
Main Menu 9 of 46
[Link] Introduction
Introduction to [Link]
[Link] 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 and
provides innovative ways to build and deploy the
next generation of ASP for use in high performance
web solutions.
[Link] is largely syntax compatible with ASP.
Main Menu 10 of 46
[Link] Introduction
How [Link] 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 [Link] page in his
browser.
An HTTP request is sent to IIS.
The [Link] filters the request and passes the
request to XSP worker process ([Link]).
Main Menu 11 of 46
[Link] Introduction
How [Link] Works
The requested .aspx page ([Link] 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.
Main Menu 12 of 46
[Link] Introduction
How [Link] 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 the
user. Requests are processed by this class and
response is prepared.
Another HTML page is generated after processing
the information sent by the user. This HTML page is
sent to the user.
Main Menu 13 of 46
[Link] Introduction
[Link] over ASP
Better Performance
• The [Link] page is not read like a new page every
time.
• An [Link] file is compiled only the first time it is
accessed.
• 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.
Main Menu 14 of 46
[Link] Introduction
[Link] over ASP
Simplicity
• [Link] 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.
Main Menu 15 of 46
[Link] Introduction
[Link] over ASP
Better tool support
• At the core of [Link] 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.
• [Link] is support for live updating of applications.
Main Menu 16 of 46
[Link] Introduction
[Link] over ASP
Language support
• [Link] supports all the languages supported by the
.NET Framework.
• [Link] currently offers support for three languages:
C#, [Link] and [Link].
Main Menu 17 of 46
[Link] Introduction
[Link] over ASP
Security
• [Link] supports HTML forms based authentication.
• [Link] 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.
Main Menu 18 of 46
[Link] Introduction
[Link] over ASP
Separation of code from html code
• You can separate your programming code from normal
HTML part.
• This makes easier to create, maintain and modify any
[Link] page.
Main Menu 19 of 46
[Link] Introduction
[Link] over ASP
Less code
• [Link] 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: -
<runat = server>
Main Menu 20 of 46
[Link] Introduction
[Link] over ASP
Caching
• Caching is a technique that is used widely to increase the
performance by keeping frequently accessed or expensive
data in memory.
• [Link] offers three types of caching
• Output caching
• Data caching
• Fragment caching
Main Menu 21 of 46
[Link] Introduction
Pre-Requisite for [Link]
[Link] 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 [Link].
• [Link]
• C#
• Jscript
Main Menu 22 of 46
[Link] Introduction
Language Support
Now let us see how [Link] supports these three
languages.
All you have to do is declare which language you
will be using in your [Link] page, in the
following syntax at the start of your page.
<%@ Page Language = “VB” %>
<%@ Page Language = “C#” %>
<%@ Page Language = “JScript” %>
VB is the default language for [Link]
Main Menu 23 of 46
[Link] Introduction
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 be
transported over the TCP/IP network between web
server and web browser.
It specifies the ways in which a browser and Web
server can interact.
Main Menu 24 of 46
[Link] Introduction
What is HTTP?
Whenever you retrieve a page from a web site, your
browser opens a connection to a web server for that
site and sends a request.
The web server receives the request and issues a
response.
All communication between a browser and a web
server takes place with the help of request and
response pair.
HTTP protocol is also known as request and
response protocol.
Main Menu 25 of 46
[Link] Introduction
What is HTTP?
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.
Main Menu 26 of 46
[Link] Introduction
Writing First [Link] Page
Configuring IIS 5.0
• To write your first [Link] page, first of all create a
directory.
• Now click on Start – Programs – Administrative Tools –
Internet Services Manager
• Now right click on Default Web Site on the left window
and select New and Virtual Directory
Main Menu 27 of 46
[Link] Introduction
Configuring IIS 5.0
Once you click on the Virtual Directory you will
view the following screen :
Main Menu 28 of 46
[Link] Introduction
Configuring IIS 5.0
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 you
that you have successfully completed the virtual
directory creation wizard. Click on finish.
Main Menu 29 of 46
[Link] Introduction
Creating [Link] Application
Open Microsoft Visual Studio .NET.
In the start page click on New Project button.
Click on [Link] 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.
Main Menu 30 of 46
[Link] Introduction
Creating [Link] 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 :
[Link]= “Hello [Link]”
Main Menu 31 of 46
[Link] Introduction
Creating [Link] 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
[Link]
Main Menu 32 of 46
[Link] Introduction
Creating [Link] Application
You will see the
following
output.
Main Menu 33 of 46
[Link] Introduction
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.
Main Menu 34 of 46
[Link] Introduction
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.
Main Menu 35 of 46
[Link] Introduction
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,
“[Link]”.
Main Menu 36 of 46
[Link] Introduction
Configuring Front Page 2002
Go to HTML tab and write the following code
<%[Link] (“Hello [Link]”) %>
Main Menu 37 of 46
[Link] Introduction
Configuring Front Page 2002
Add a hyperlink in home page which points to the
new .aspx page by clicking on Menu Item Insert
Hyperlink.
Main Menu 38 of 46
[Link] Introduction
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
[Link] and click on PUBLISH Button.
Main Menu 39 of 46
[Link] Introduction
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.
Main Menu 40 of 46
[Link] Introduction
Configuring Front Page 2002
Click on the hyperlink on the web page to display
your .aspx page on the web browser.
Main Menu 41 of 46
[Link] Introduction
Configuring Front Page 2002
The Output would be as follows :
Main Menu 42 of 46
[Link] Introduction
Summary
Key points covered in this chapter are:
• ASP lacks in performance as it supports scripting languages
only. [Link] has been introduced by Microsoft under
.NET framework, to overcome the drawbacks of ASP
• To understand [Link], you should have knowledge of
any language supported in .NET Framework and familiarity
with the environment of Visual [Link].
• [Link] provides lots of advantages over ASP e.g.
performance, tool support, rich hierarchy, separation of
code from HTML code, less code, caching etc.
Main Menu 43 of 46
[Link] Introduction
Summary
• [Link] 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.
• [Link] page or the Web Forms can be created from a
simple notepad or the Visual [Link] IDE and even
from Front Page 2002.
• Configuration of IIS 5.0 Server
• Configuration of Front Page Server extensions.
Main Menu 44 of 46
[Link] Introduction
Self Assessment
State True or False
• ASP understands only compile type languages.
• [Link] has replaced ASP completely.
• [Link] is interpreted at the server.
• ASP supports only 3 objects.
• [Link] supports C# and VB.
• [Link] supports JavaScript.
• [Link] supports caching.
• [Link] requires heavy coding from the developer for
any task.
Main Menu 45 of 46
[Link] Introduction
Self Assessment
Fill in the blanks
• Caching is used to save ______________ accessed data at
the server end. (Frequently / rarely).
Main Menu 46 of 46