Vous êtes sur la page 1sur 11

Web Server Architecture

Web server is software that manages web pages, provides security for the web pages,
accepts http request from client, and responds with http response to the client. Hence web server
is also called as http server. It also provides security for local file system on server and supports
server side code execution for communication with other servers like database server and email
server.

Client

Web Server
Request
Web
Pages

Browser
Response

Communication is possible between client and server only when both maintain standards
in the language used for communication. A set of rules to be accepted by client and server for
communication is called as protocol. Hypertext transfer protocol (Http) is used for client and
web server communication.
APACHE tomcat web server, Java web server, Personnel web server, peer web server
and internet information services (IIS) are available web servers. ASP.net requires IIS 5.0 and
higher while classic ASP works on any web server of Microsoft.
ASP.net 2.0 comes with an in built web server called Cassini and you can create a
web application in ASP.net 2.0 using IIS or Cassini.

Internet Information Services (IIS)


In case of windows 2000 and windows 2003 server IIS will be installed along with
operating system installation. But in windows XP you have to install it manually and for this
purpose follow the following steps.
1. Open Add/Remove programs in control panel.
2. Click on Add/Remove Windows Components within Add/Remove Programs window.
3. Check Internet Information Services (IIS) and click on next.
4. Provide operating system CD if needed.
5. After installation to check whether IIS is working properly, open browser and type the URL
http://localhost or http://servername and it has to display IIS documentation.

6. IIS installation will carry a web site called as default web site.
7. A web site is an application managed by web server that will provide physical location of
web page.
8. Default web site is mapped to physical path C:\inetpub\wwwroot.
9. Client will just send a request to web server and will not know the physical location of web
page.
Creating A Web Page Into Default Web Site (Demo.Html)
<Html>
<Body>
<H1>
This Is My First Web Page Managed By Web Server
</H1>
</Body>
</Html>
Save this file in C:\inetpub\wwwroot and then use the following URL to run the web
page in web browser http://localhost (or) ServerName/Demo.Html.

Web Server
Request
Client

Inetinfo.e
xe

8
0

Default
Web Site

Response
C:\InetPub\WwwRoot\
Demo.Html

Port number is a logical one, which provides uniqueness for a particular service. This will
connect client request with a particular service. Hence it is called as end point for
communication. Default port number for HTTP is 80.

Virtual Directory
Virtual directory is an alias for a physical directory. This will perform categorization of web
pages, which will make access to web pages fast and provides security for web pages. Internet
Services Manager (Inetmgr.exe) is used to configure web server. Web server configuration
includes

Creating a web site

Creating a virtual directory

Changing physical path of web site using properties of web site

To specify number of connections to a web site using properties of web site.

Creating Virtual Directory

Within Run option of start menu type Inetmgr and click on ok.

Right click on default web site and choose new virtual directory.

Provide an alias name i.e. virtual directory name.

Select physical directory name and path.

Finally click on finish.

Create an example web page in new virtual directory and to run specify the following URL.
http://localhost/virtualdirectoryname/demo.html

Server Side Code Execution


To execute the code towards client side scripting languages like java script and VB script
are used. The solution for executing code by the server is ASP.Net. ASP.net is a technology
integrated with IIS. ASP.net Comes in the form of a DLL file called ASP.Dll. This provides server
side code execution.
ASP.net is the technology integrated with .net framework. During the installation of .net
framework, a run time module called AspNet_IsApi.Dll (Internet Server Application
Programming Interface) is configured with web server for communication between web server
and .net framework.

Browser
Http://localhost/Asp
net/
Time.Aspx

Web Server
InetInfo.exe
ASPNet_IsApi
.Dll
ASP.Dll

.Net
Framework

ASP.net comes with two things. Scripting languages support on server machine and a
collection of objects called ASP.net objects like Response, Request, Session, Application and
Server. ASP.net page extension is .Aspx.
Server side script requires identification i.e. uniqueness and uniqueness is provided as
follows.
1. <%= Statement %>

For Single Statement

2. <% Statement1,Statement2, %>

For Multiple Statements

3. <Script Language=javascript/vbscript Runat=server>


Statements
</Script>
Example : (Time.Aspx)
<Html>
<Body>
<H2>
Server Time : <%=DateAndTime.TimeString%>
</H2>
</Body>
</Html>

ASP.Net Page Execution


Browser
Http://localhost/Aspnet/Time.As
px

HTML Tags

Temporary Page

Temp.
Page

InetInfo.Exe

ASP.DLL

Activates VB, executes server


side code and output will be
copied to Temporary memory

The response generated for the client will not contain server side code and contain only
HTML and text.

Request And Response


when a request was made by the client to the server, IP address, data entered into the
form, browser information and culture information will be sent to the server along with request.
Request object of ASP.net is used to read information submitted by the client. Response object
can be used to send information to the client browser.
Example (Wish.Aspx)
<Html>
<Body>
<%
If DateAndTime.TimeString>=#12:00:00AM# and DateAndTime.
TimeString <=#12:00:00PM# then
Response.write(<H2>Good Morning</H2>)
Else
Response.Write(<H2>Good Evening</H2>)
End If
%>
</Body>
</Html>

Page Submission
The process of submitting data by the client to the server is called as page submission.
Client will submit the data through HTML page, while server read it from an ASP.net Page.
<Html>
<Body>
<Form Method=Post/Get Action=ASP.Net Page>
<Input Type=Submit value=Sign in>
</Form>
</Body>
</Html>

Method attribute will specify the standards for arranging data. If method is post, the data
will be arranged within HTTP message body and this will not be visible to the user. This provides
security for the sensitive data i.e. password, Credit card number, bank account number etc.,
If method is get, the data will be arranged within HTTP header by appending to the URL
in the form of query string. This doesnt provide security for sensitive data.
If method is post, large amount of data can be submitted. If method is get, small amount
of data can be submitted i.e. maximum of 2KB. Hence data transmission will be fast.
Action attribute will specify ASP.Net page for which data to be submitted. Following
methods are used to read data submitted by client in ASP.net page.
If method is post , Request.Form(Control Name)
If methos is Get, Request.QueryString(ControlName)
Example (Login.Html)
<Html>
<Body>
<Form Method=Post Action=Http://localhost/Aspnet/login.Aspx>
User Name : <input Name=T1><Br>
Password : <input type=Password name=T2><Br>
<input type=submit value=Sign in>
</Form>
</Body>
</Html>
Login.Aspx
<%
Dim Uname as string
Dim Pwd as string
Uname = Request.Form(T1)
Pwd = Request.Form(T2)
Response.Write(<H1 align=center> Welcome To & Uname & </H2>)
%>

Post Back Implementation


The process of submitting a page to it self is called as post back implementation. To stop
server side code execution, use response.end statement. In classic ASP controls data will not
be maintained under post back implementation and if it is required, the developer should perform
manual coding.
Example (Sum.Aspx)
<html>
<body>
<form method=post action=sum.aspx>
A : <input name=t1><br>
B : <input name=t2><br>
<input type=submit value=sum>
</form>
</body>
</html>
<%
Dim A,B,Res as integer
A=request.form(t1)
B=request.form(t2)
If A= and B= then
Response.end
End if
Res=A+B
Response.write(<h2> Sum = & Res & <h2>)
%>

Directives
Directive is an instruction to the server and must always be written as the first statement
in ASP.net Page.
Import Directive : used to import a namespace and avoid repetition of namespace.
<%@ import namespace=namespace1,namespace2,%>
<%@ import namespace=Microsoft.VisualBasic%>

Page Directive : the default language for asp.net page is vb.net. to change the language for
ASP.net page, you can use page directive.
<%@page language=VB/CS%>
Example (SumCs.html)
<html>
<body>
<form method=post action=sum.aspx>
A : <input name=t1><br>
B : <input name=t2><br>
<input type=submit value=sum>
</form>
</body>
</html>
SumCs.Aspx
<%@page language=CS%>
<%
int A,B,Res;
A=int.Parse(Request.Form[t1]);
B=int.Parse(Request.Form[t2]);
Res=A+B;
Response.write(<h2> Sum = & Res & <h2>);
%>

Web Page Creation Techniques


A web page will have two parts, logic part that is used to communicate with database
and design part that is used to position the controls and integrating flash. In general design part
will be taken by the web designer and logic part will be taken by the web developer. In classic
ASP, design part as well as logic part will be placed in a single file called ASP. This will create
two problems.

Application Development will become slow

No security for the logic part.

These problems have been overcome in ASP.net by supporting code behind technique.
ASP.net supports two techniques for creating a web page.

Inpage Technique : when the design part code and logic part code are maintained in a single
file, then the technique is called as inpage technique and is similar to classic ASP. The purpose
of providing this in ASP.net is making migration process easier.

.Aspx
Design
Part Code

Logic Part
Code

Code Behind technique : separating design part code to .ASPX file and logic part code to
a .cs or .vb file is called as code behind technique. Advantages of code behind technique are
1. It supports parallel development of designing and logic part that will make application
development faster.
2. The logic part will not be provided for the web designer by maintaining in the form of DLL
file that will provide security for the logic part.

.Aspx

.DLL

Design Part
Code

Logic Part
Code

HTML Server Controls


These controls are not able to detect browser

Web Server Controls


These controls can detect browser capabilities.

capabilities. Hence you need to write code for

No need to write code for browser compatibility.

browser compatibility.
These controls can be processed on server or

These controls have no choice and are

in browser based on the code.


These controls cant be referred in code behind
These are light weight controls with limited

processed only on server.


These controls can be referred in code behind.
These controls contain a rich set of properties,

properties, methods and event handlers.


These
controls
are
available
within

methods and events.


These
controls
are

System.Web.UI.HtmlControls

available

namespace System.Web.UI.WebControls

within

namespace

and their base class is HTMLControl


These are provided to make migration process

and their base class is WebControl


When we are starting the project from scratch,

easy.

not migrating, it is recommended to use web


server controls only.

Vous aimerez peut-être aussi