ASP Net 2005
ASP Net 2005
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.
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
Within Run option of start menu type Inetmgr and click on ok.
Right click on default web site and choose new virtual directory.
Create an example web page in new virtual directory and to run specify the following URL.
http://localhost/virtualdirectoryname/demo.html
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 %>
HTML Tags
Temporary Page
Temp.
Page
InetInfo.Exe
ASP.DLL
The response generated for the client will not contain server side code and contain only
HTML and text.
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>)
%>
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>);
%>
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
browser compatibility.
These controls can be processed on server or
System.Web.UI.HtmlControls
available
namespace System.Web.UI.WebControls
within
namespace
easy.