New Information Technology
ASP.NET 1 and 2
ASP.NET
By: Dr. Galal AL-Marzoqi
Lecture (1 and 2 )
ASP.NET
Active Server Page (ASP. NET), it is a web framework designed and developed by
Microsoft. It is used to develop websites, web applications and web services. It
provides fantastic integration of HTML, CSS and JavaScript. It is used for creating
web-based applications. ASP.Net was first released in the year 2002.The following
image shows the component stack.
Fig: .NET framework components
Common Language Runtime (CLR) is a managed execution location that is part of
Microsoft’s .NET framework, and manages the execution of programs written in different
supported languages, security checking, thread execution, code execution, code safety and
verification.
Net Framework Class Library contains a huge library of reusable types, classes, interfaces,
structures, and enumerated values.
Windows Forms (WinForms) contains the graphical representation of any window
displayed in the application.
ASP.NET is the web development model and AJAX is an extension of ASP.NET for
developing and implementing AJAX functionality.
ADO.NET is the part of the .NET Framework that enables you to access data and data
services like SQL Server and many other different kinds of data
sources.
2
ASP.NET Architecture and its Components
ASP.Net is a framework which is used to develop a Web-based application. The basic
architecture of the ASP.Net framework is as shown below.
ASP.NET Architecture Diagram
The architecture of the .Net framework is based on the following key components
1. Language – A variety of languages exists for .Net framework. They are
VB.Net and C#. These can be used to develop web applications.
2. Library - The .Net Framework includes a set of standard class libraries. The
most common library used for web applications in .Net is the Web library. The web
library has all the necessary components used to develop .Net web-based
applications.
3. Common Language Runtime (CLR) - The CLR is used for performing key
activities. Activities include Exception handling and Garbage collection.
3
ASP.NE Work
When you type a URL like www.facebook.com in your web browser and press Enter,
the browser sends a request to the web server at that address. This is done through HTTP,
the HyperText Transfer Protocol. HTTP is the protocol by which web browsers and web
servers communicate. When you request the URL, you send a request to the server. When
the server is active and the request is valid, the server accepts the request, processes, and
then sends the response back to the client browser.
The relationship between the request and response is shown in Figure below.
ASP.NE Work
There are three Main areas effect on page in browser:
1. Static text: Any static text, like HTML, CSS, or JavaScript code you place in a page,
is sent to the browser directly.
2. ASP.Net Server Controls: These controls are placed in your ASPX page and when
they are processed, they produce HTML that is inserted in the page.
Note: aspx is the filename for a page designed by ASP.Net. The ASP.Net is a server-
side Web application framework. ASPX stands for Active Server Pages Extended. It
was designed for Web development to produce dynamic Web pages.
3. Programming code: You can insert code, like Visual Basic .Net or C#, directly in a
page.
4
ASP.Net Page Lifecycle
In ASP.Net, a web page has execution lifecycle that includes various phases. These
phases include Page request, Start, initialization, Load, Postback event handling,
Rendering, and Unload state.
The following table contains the lifecycle Phases of ASP.NET web page.
Phase Description
Page request The page is requested by the user, ASP.NET describes and organizes that page.
Start In this stage, page properties such as Request and response are set.
Page Initialization In this stage, each control's UniqueID property is set. Master page is applied to the page.
Page Load request is postback, control properties are with information.
Postback event handling Validate method of all controls.
Rendering the page calls the Render method for each control, providing a text writer that writes its
output.
Unload All properties are unloaded and cleanup is performed.
5
Fig. ASP.NET Page Lifecycle
Types of Project in ASP.Net
There are two types of projects for creating ASP.Net Web Forms websites:
(1. Web Application Projects and 2. Web Site Projects).
1. Web Application Projects
Web application Project is a software application that can be run without being
installed on the client and that has several parts: A part of it will run on the remote
web server, another part will run on the client, usually inside a web browser.
6
Common examples of web application projects are those used for (web mail, or for
online banking. Social media sites, such as Wikipedia).
2. Web Site Projects
A website project is a process of developing and creating a Web site, activities in a
network that are aimed at a pre-defined goal. The network can be easy for everyone
on the Internet, or only for special people, as an intranet. The goal of Website project
projects is the transfer of static and dynamic content - both directly to end-users, as
well as indirectly through means of various kinds of interfaces.
So A Web Site Project site is simply a Windows folder with a group of files and
subfolders in it. This makes it very easy to create copies of the site, move them, and share
them with others and it’s easier to copy the files to a different location.
Website Templates
The New Web Site dialog box in VS contains different website templates, each one
serving a different purpose. There are 5 templates: see figure below:
1. ASP.Net Web Forms Site
This template contains files and folders to jump-start the development of your site.
This template is a good starting point once you start developing real-world ASP.Net
websites.
2. ASP.Net Web Site (Razor v1 / Razor v2)
You use these templates to create sites using Microsoft’s Web Pages framework.
7
3. ASP.Net Empty Web Site
The ASP.Net Empty Web Site template gives you nothing but a single configuration
file (Web .config). The ASP.Net Empty Web Site template is useful if you have a
collection of existing files you want to use to create a new website or when you want to
create your site from scratch.
4. ASP.Net Dynamic Data Entities Web Site
This template enables you to create a flexible yet powerful website to manage data
in a database without a lot of manual code.
5. WCF Service
This template enables you to create a website containing one or more Windows
Communication Foundation (WCF) Services. A WCF Service is similar to a web
service in that it enables you to create methods that are callable over a network.
o File categories
The files you can add to a site can be grouped in a few different categories, such as
(Web Files, Code Files and Data Files)
• Web files: are specific to web applications and can either be
requested by a browser directly, or used to build up part of the web
page that is requested in the browser. The following table lists the
various web files you typically use in an ASP.Net Web Forms website
and their extensions, and describes how each file is used. See in table
below:
8
• Code Files, Adding Code files to the site, to how you add web files.
The following table describes the various types of code files.
9
• Data Files, Data files are used to store data that can be used in your
site and in other applications. The group consists of the XML fi les,
database fi les, and fi les related to working with data.
10