Sei sulla pagina 1di 44

ASP.

NET
ASP.Net
• ASP.Net is a web development platform provided by Microsoft. It is
used for creating web-based applications. ASP.Net was first released
in the year 2002.
• The first version of ASP.Net deployed was 1.0. ASP.Net is designed to
work with the HTTP protocol. This is the standard protocol used
across all web applications.
• ASP.Net applications can also be written in a variety of .Net
languages. These include C#, VB.Net, and J#. In this chapter, you will
see some basic fundamental of the .Net framework.
• The full form of ASP is Active Server Pages, and .NET is Network
Enabled Technologies.
ASP.NET Architecture and its Components
• The architecture of the.Net framework is based on ASP.Net is a framework which is used to develop a
the following key components Web-based application. The basic architecture of the
• Language – A variety of languages exists for .net ASP.Net framework is as shown
framework. They are VB.net and C#. These can be
used to develop web applications.

• 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.

• Common Language Runtime - The Common


Language Infrastructure or CLI is a platform. .Net
programs are executed on this platform. The CLR is
used for performing key activities. Activities include
Exception handling and Garbage collection.
Characteristics of the ASP.Net framework
• Code Behind Mode – This is the concept of separation of design and code.
By making this separation, it becomes easier to maintain the ASP.Net
application. The general file type of an ASP.Net file is aspx. Assume we
have a web page called MyPage.aspx. There will be another file called
MyPage.aspx.cs which would denote the code part of the page. So Visual
Studio creates separate files for each web page, one for the design part
and the other for the code.

• State Management – ASP.Net has the facility to control state management.

• Caching – ASP.Net can implement the concept of Caching. This improves


the performance of the application. By caching those pages which are
often requested by the user can be stored in a temporary location. These
pages can be retrieved faster and better responses can be sent to the user.
So caching can significantly improve the performance of an application.
ASP.Net Lifecycle
• When an ASP.Net application is
launched, there are series of steps which
are carried out. These series of steps
make up the lifecycle of the application.
• Let's look at the various stages of a
typical page lifecycle of an ASP.Net Web
Application.
Application Start - The life cycle of an ASP.NET application starts when a request is made by a user. This
request is to the Web server for the ASP.Net Application. This happens when the first user normally goes to the
home page for the application for the first time. During this time, there is a method called Application_start which
is executed by the web server. Usually, in this method, all global variables are set to their default values.

Object creation - The next stage is the creation of the HttpContext, HttpRequest & HttpResponse by the web
server. The HttpContext is just the container for the HttpRequest and HttpResponse objects. The HttpRequest
object contains information about the current request, including cookies and browser information. The
HttpResponse object contains the response that is sent to the client.
• HttpApplication creation - This object is created by the web server. It
is this object that is used to process each subsequent request sent to
the application. For example, let's assume we have 2 web
applications. One is a shopping cart application, and the other is a
news website. For each application, we would have 2 HttpApplication
objects created. Any further requests to each website would be
processed by each HttpApplication respectively.
• Dispose - This event is called before the application instance is
destroyed. During this time, one can use this method to manually
release any unmanaged resources.
• Application End - This is the final part of the application. In this part,
the application is finally unloaded from memory.
ASP.Net Page Lifecycle
When an ASP.Net page is called, it
goes through a particular lifecycle.
This is done before the response is
sent to the user. There are series
of steps which are followed for the
processing of an ASP.Net page.
• Page Request- This is when the page is first requested from the server. When the page is requested, the
server checks if it is requested for the first time. If so, then it needs to compile the page, parse the response
and send it across to the user. If it is not the first time the page is requested, the cache is checked to see if
the page output exists. If so, that response is sent to the user.
• Page Start – During this time, 2 objects, known as the Request and Response object are created. The Request
object is used to hold all the information which was sent when the page was requested. The Response object
is used to hold the information which is sent back to the user.
• Page Initialization – During this time, all the controls on a web page is initialized. So if you have any label,
textbox or any other controls on the web form, they are all initialized.
• Page Load – This is when the page is actually loaded with all the default values. So if a textbox is supposed to
have a default value, that value is loaded during the page load time.
• Validation – Sometimes there can be some validation set on the form. For example, there can be a validation
which says that a list box should have a certain set of values. If the condition is false, then there should be an
error in loading the page.
• Postback event handling – This event is triggered if the same page is being loaded again. This happens in
response to an earlier event. Sometimes there can be a situation that a user clicks on a submit button on the
page. In this case, the same page is displayed again. In such a case, the Postback event handler is called.
• Page Rendering – This happens just before all the response information is sent to the user. All the
information on the form is saved, and the result is sent to the user as a complete web page.
• Unload – Once the page output is sent to the user, there is no need to keep the ASP.net web form objects in
memory. So the unloading process involves removing all unwanted objects from memory.
First Web Application
• Click on New then Project
• Select Web then ASP.NET Web Application
• Click on OK button. It will create new empty website. On Right side solution
explorer . You will get Default.aspx and in it Default.aspx.cs page.

• ASP.NET provides two types of coding model.


Code-inline model.
• Code-behind model.
• In code inline model, your logic and presentation code are written in a single aspx
page.
Code-behind model provides clean code separation of the page’s business logic
from its presentation logic. Your presentation logic goes in .aspx file and your cs
or vb code (business logic) in .aspx.cs file.
Default.aspx Default.aspx.cs

using System;
<%@ Page Language="C#" AutoEventWireup="true" using System.Collections.Generic;
CodeFile="Default.aspx.cs" Inherits="_Default" %>
using System.Linq;
<!DOCTYPE html> using System.Web;
<html xmlns="http://www.w3.org/1999/xhtml"> using System.Web.UI;
<head runat="server"> using System.Web.UI.WebControls;
<title></title>
</head> public partial class _Default : System.Web.UI.Page
<body> {
<form id="form1" runat="server"> protected void Page_Load(object sender, EventArgs e)
<div> {
}
</div>
</form> }
</body>
</html>
• Default.aspx page is starts with page directive.
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs"
Inherits="_Default" %>
In ASP.NET a directive always begins with the special characters <%@ and ends
with the characters %>.
When the page is compiled, directive provides the important information to
compiler.
General syntax of a directive is as follows.
<%@ [Directive] [Attribute=Value] %>
ASP.NET First Program
• The first step involves the creation of a new project in Visual Studio. After launching Visual Studio,
you need to choose the menu option New->Project.
• The next step is to choose the project type as an ASP.Net Web application. Here we also need to
mention the name and location of our project.
In the project dialog box, you can see various options for creating different types of projects.
Click the Web option on the left-hand side.
When we click the Web option in the previous step, we will be able to see an option for
ASP.Net Web Application. Click this option.
We then give a name for the application, which in our case is DemoApplication. We also
need to provide a location to store our application.
Finally, we click the 'OK' button to let Visual Studio to create our project.
• If the above steps are followed, you will get the default.aspx file in tab of Visual Studio. And at right
hand side you will find Solution Explorer
• If you follow all of the above steps and run your program in Visual Studio, you will get the default
output displayed in the browser.
Directive in ASP.NET
• Assembly
• Control
• Implements
• Import
• Master
• MasterType
• OutputCache
• Page
• PreviousPageType
• Reference
• Register
@Page directive: This directive is used by every .aspx page and controls the behavior of asp.net page. It
provides the important information to compiler.

@Master directive: It similar to page directive but mainly used with master page. @Master directive has
less attributes than @Page directive.

@Control directive: When you create custom/user ASP.NET control, then control directive is used. It
allows you to create the properties to be inherited by the user control.

@Import directive: The @Import directive is used to import a namespace into the ASP.NET page or user
control. By using particular namespace with the help of import directive, all the classes and interfaces of
the namespace are available to the page or user control.

@Implements directive: The @Implements directive is used to implement .NET Framework interface. This
directive supports only a single attribute name as Interface.

@Register directive: This directive comes in picture when you drag and drop a user control onto any of
your .aspx pages. When you drag a user control onto the .aspx page, @Register directive creates
automatically at the top of the page.
@Assembly directive: The @Assembly directive attaches assemblies in
web pages.
@PreviousPageType directive: It is used for Cross-page posting between
ASP.NET pages.

@MasterType directive: This directive is used, when the master page is


accessed from the Master property.
@OutputCache directive: It is used for Page Output Caching. It catches the
page for given time duration.
@Reference directive: As it name suggests it refer to another ASP.NET
page or user control. Referred page is compiled along with ASP.NET page.
ASP.NET Web Forms
• Web Forms are web pages built on the ASP.NET
Technology. It executes on the server and generates
output to the browser. It is compatible to any
browser to any language supported by .NET common
language runtime. It is flexible and allows us to create
and add custom controls.
• We can use Visual Studio to create ASP.NET Web
Forms. It is an IDE (Integrated Development
Environment) that allows us to drag and drop server
controls to the web forms. It also allows us to set
properties, events and methods for the controls. To
write business logic, we can choose any .NET
language like: Visual Basic or Visual C#.
• Web Forms are made up of two components: the
visual portion (the ASPX file), and the code behind
the form, which resides in a separate class file.
• The main purpose of Web Forms is to overcome the
limitations of ASP and separate view from the
application logic.
ASP.NET Web Forms Features
ASP.NET is full of features and provides an awesome platform to create and
develop web application. Here, we are discussing these features of Web
Forms.
• Server Controls
• Master Pages
• Working with data
• Membership
• Client Script and Client Frameworks
• Routing
• State Management
• Security
• Performance
• Error Handling
• Server Controls: Web Forms provides rich set of server controls. These controls are
objects that run when the page is requested and render markup to the browser.
Some Web server controls are similar to familiar HTML elements, such as buttons
and text boxes. It also provides controls that we can use to connect to data
sources and display data.
• Master Pages: It allows us to create a consistent layout for the pages in our
application. This page defines the look and feel and standard behavior that we
want for all of the pages in our application. When users request the content pages,
they merge with the master page to produce output that combines the layout of
the master page with the content from the content page.
• Working with Data: In an ASP.NET Web Forms application, we use data-bound
controls to automate the presentation or input of data in web page UI elements
such as tables and text boxes and drop-down lists.
• Membership: Project's Account folder contains the files that implement the
various parts of membership: registering, logging in, changing a password, and
authorizing access. Additionally, ASP.NET Web Forms supports OAuth and OpenID.
These authentication enhancements allow users to log into your site using existing
credentials, from such accounts as Facebook, Twitter and Google.
• Client Script and Client Frameworks: We can enhance the server-based features of
ASP.NET by including client-script functionality in ASP.NET Web Form pages. We can use
client script to provide a richer, more responsive user interface to the users. We can also
use client script to make asynchronous calls to the Web server while a page is running in
the browser.
• Routing: We can configure URL routing of our application. A request URL is simply the URL
a user enters into their browser to find a page on our web site. We use routing to define
URLs that are semantically meaningful to users and that can help with search-engine
optimization (SEO).
• State Management: ASP.NET Web Forms includes several options that help you preserve
data on both a per-page basis and an application-wide basis.
• Security: Developing a secure application is most important aspect of software
development process. ASP.NET Web Forms allow us to add extensibility points and
configuration options that enable us to customize various security behaviors in the
application.
• Performance: Web Forms provides good performance and allows us to modify
performance related to page and server control processing, state management, data
access, application configuration and loading, and efficient coding practices.
• Debugging and Error Handling: We can diagnose problems that occur in our Web Forms
application. Debugging and error handling are well supported within ASP.NET Web Forms
so that our applications compile and run effectively.
ASP.NET Web Forms Project
• We are using Visual
studio 2017 to create
web project. It includes
the following steps:
• Creating a new project:
Click on the file menu
from the menu bar and
select new -> project.
Select Project type: It provides couple of choices but we selecting ASP.NET Web
Application.
• Select Project Template
• After selecting project types,
now, it asks for the type of
template that we want to
implement in our application.
• Here, we are selecting Web
Forms as because we are
creating a Web Forms
application.
After clicking ok, it shows project in solution explorer window that looks like the
below.
• This project contains
a default.aspx file which is
a startup file. When we run
the project this file
executes first and display a
home page of the site.
• We can see its output on
the browser by
selecting view in
browser option as we did
below.
Finally, it shows output in the browser like this:
Create a New Web Form: To add a new web form in our existing project, first select project
then right click and add new item

.
Select web forms option in left corner and then select web form and hit add
button.
Now click on the add button and this form will add to our project.
After adding form, we can see that this is now in our project as we have shown in
the below image.
Double click on this form and this will show some auto generated code like this:
// user-form.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="user-
form.aspx.cs"
Inherits="asp.netexample.user_form" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
</div>
</form>
</body>
</html>

If we run this file on the browser, it does not show any output. So, let's print some message by this form.
The modified code is as below.
// user-form.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="user-form.aspx.cs"


Inherits="asp.netexample.user_form" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<h2>Welcome to the Web Forms!</h2>
</div>
</form>
</body>
</html>
After running it on the browser it yields the following output.

ASP.NET provides various controls like: server controls and HTML controls for the Web Forms.
Server Controls
Control Name Applicable Events Description
Label None It is used to display text on the HTML page.
TextBox TextChanged It is used to create a text input in the form.
Button Click, Command It is used to create a button.
LinkButton Click, Command It is used to create a button that looks similar to the hyperlink.
ImageButton Click It is used to create an imagesButton. Here, an image works as a Button.
Hyperlink None It is used to create a hyperlink control that responds to a click event.
DropDownList SelectedIndexChanged It is used to create a dropdown list control.
ListBox SelectedIndexCnhaged It is used to create a ListBox control like the HTML control.
DataGrid CancelCommand, EditCommand, DeleteCommand, It used to create a frid that is used to show data. We can also perform paging, sorting, and formatting very
ItemCommand, SelectedIndexChanged, easily with this control.
PageIndexChanged, SortCommand,
UpdateCommand, ItemCreated, ItemDataBound
DataList CancelCommand, EditCommand, DeleteCommand, It is used to create datalist that is non-tabular and used to show data.
ItemCommand, SelectedIndexChanged,
UpdateCommand, ItemCreated, ItemDataBound
Repeater ItemCommand, ItemCreated, ItemDataBound It allows us to create a non-tabular type of format for data. You can bind the data to template items, which are
like bits of HTML put together in a specific repeating format.

CheckBox CheckChanged It is used to create checkbox.


CheckBoxList SelectedIndexChanged It is used to create a group of check boxes that all work together.
RadioButton CheckChanged It is used to create radio button.
RadioButtonList SelectedIndexChanged It is used to create a group of radio button controls that all work together.
Image None It is used to show image within the page.
Panel None It is used to create a panel that works as a container.
PlaceHolder None It is used to set placeholder for the control.
Calendar SelectionChanged, VisibleMonthChanged, DayRender It is used to create a calendar. We can set the default date, move forward and backward etc.

AdRotator AdCreated It allows us to specify a list of ads to display. Each time the user re-displays the page.
Table None It is used to create table.
XML None It is used to display XML documents within the HTML.
Literal None It is like a label in that it displays a literal, but allows us to create new literals at runtime and place them into
this control.
ASP.NET Web Forms Label Property

AccessKey
Description

It is used to set keyboard shortcut

• This control is used to display textual TabIndex


for the label.
The tab order of the control.
information on the web forms. It is BackColor It is used to set background color
of the label.
mainly used to create caption for the BorderColor It is used to set border color of the
label.
other controls like: textbox. BorderWidth It is used to set width of border of
the label.
• This is server side control, asp provides Font It is used to set font for the label
text.
own tag to create label. The example is ForeColor It is used to set color of the label
given below. Text
text.
It is used to set text to be shown

• < asp:LabelID="Label1" runat="server" T ToolTip


for the label.
It displays the text when mouse is
ext= "Label" ></asp:Label> Visible
over the label.
To set visibility of control on the
form.
• This control has its own properties that Height It is used to set height of the
control.
are tabled . Width It is used to set width of the
control.
ASP.NET Web Forms TextBox Property Description

AccessKey It is used to set keyboard shortcut for the control.


• This is an input control which is used to take
user input. To create TextBox either we can TabIndex The tab order of the control.

write code or use the drag and drop facility of BackColor It is used to set background color of the control.

visual studio IDE. BorderColor It is used to set border color of the control.

• This is server side control, asp provides own BorderWidth It is used to set width of border of the control.
tag to create it. The example is given below.
• < asp:TextBoxID="TextBox1" runat="server" > Font It is used to set font for the control text.

</asp:TextBox> ForeColor It is used to set color of the control text.

• Server renders it as the HTML control and Text It is used to set text to be shown for the control.
produces the following code to the browser.
ToolTip It displays the text when mouse is over the control.
• <input name="TextBox1" id="TextBox1" type
="text"> Visible To set visibility of control on the form.

• This control has its own properties that are Height It is used to set height of the control.

tabled
Width It is used to set width of the control.

MaxLength It is used to set maximum number of characters that can


be entered.

Readonly It is used to make control readonly.


ASP.NET Web Forms Button Property Description

• This control is used to perform events. It is also used AccessKey It is used to set keyboard shortcut for the
control.
to submit client request to the server. To
TabIndex The tab order of the control.
create Button either we can write code or use the
drag and drop facility of visual studio IDE. BackColor It is used to set background color of the
control.
• This is a server side control and asp provides own tag BorderColor It is used to set border color of the control.
to create it. The example is given below.
• < asp:ButtonID="Button1" runat="server" Text="Sub BorderWidth It is used to set width of border of the control.

mit" BorderStyle="Solid" ToolTip="Submit"/> Font It is used to set font for the control text.
• Server renders it as the HTML control and produces
the following code to the browser. ForeColor It is used to set color of the control text.

• <input name="Button1" value="Submit" id="Button1 Text It is used to set text to be shown for the
" title="Submit" style="border- control.
style:Solid;" type="submit"> ToolTip It displays the text when mouse is over the
control.
• This control has its own properties that are tabled Visible To set visibility of control on the form.

Height It is used to set height of the control.

Width It is used to set width of the control.


ASP.NET Web Forms HyperLink
Property Description
• It is a control that is used to create a hyperlink. It AccessKey It is used to set keyboard shortcut for the control.
responds to a click event. We can use it to refer any web
page on the server. TabIndex The tab order of the control.

• To create HyperLink either we can write code or use the BackColor It is used to set background color of the control.
drag and drop facility of visual studio IDE. This control is
listed in the toolbox. BorderColor It is used to set border color of the control.

• This is a server side control and ASP.NET provides own tag BorderWidth It is used to set width of border of the control.
to create it. The example is given below.
Font It is used to set font for the control text.
• < asp:HyperLinkID="HyperLink1" runat="server" Text="Jav
aTpoint" NavigateUrl="www.javatpoint.com" ></asp:Hyp ForeColor It is used to set color of the control text.
erLink>
• Server renders it as the HTML control and produces the Text It is used to set text to be shown for the control.

following code to the browser. ToolTip It displays the text when mouse is over the control.
• <a id="HyperLink1" href="www.javatpoint.com">JavaTpoi
nt</a> Visible To set visibility of control on the form.

• This control has its own properties that are tabled below. Height It is used to set height of the control.

Width It is used to set width of the control.

NavigateUrl It is used to set navigate URL.


Target Target frame for the navigate url.
ASP.NET Web Forms RadioButton
Property Description
• It is an input control which is used to takes input from AccessKey It is used to set keyboard shortcut for the control.
the user. It allows user to select a choice from the
group of choices. TabIndex The tab order of the control.
• To create RadioButton we can drag it from the toolbox BackColor It is used to set background color of the control.
of visual studio.
BorderColor It is used to set border color of the control.
• This is a server side control and ASP.NET provides own
tag to create it. The example is given below. BorderWidth It is used to set width of border of the control.
• < asp:RadioButtonID="RadioButton1" runat="server" Te
xt="Male" GroupName="gender"/> Font It is used to set font for the control text.

• Server renders it as the HTML control and produces the ForeColor It is used to set color of the control text.
following code to the browser.
Text It is used to set text to be shown for the control.
• <input id="RadioButton1" type="radio" name="gender"
value="RadioButton1" /><labelforlabelfor="RadioButt ToolTip It displays the text when mouse is over the control.
on1">Male</label>
• This control has its own properties that are tabled Visible To set visibility of control on the form.

below.
Height It is used to set height of the control.

Width It is used to set width of the control.

GroupName It is used to set name of the radio button group.


ASP.NET Web Forms CheckBox
Property Description
• It is used to get multiple inputs from the user. It AccessKey It is used to set keyboard shortcut for the control.
allows user to select choices from the set of choices.
TabIndex The tab order of the control.
• It takes user input in yes or no format. It is useful
BackColor It is used to set background color of the control.
when we want multiple choices from the user.
• To create CheckBox we can drag it from the toolbox BorderColor It is used to set border color of the control.
in visual studio.
BorderWidth It is used to set width of border of the control.
• This is a server side control and ASP.NET provides
own tag to create it. The example is given below. Font It is used to set font for the control text.

• < asp:CheckBox ID="CheckBox2" runat="server" Text


ForeColor It is used to set color of the control text.
="J2EE"/>
• Server renders it as the HTML control and produces Text It is used to set text to be shown for the control.
the following code to the browser.
ToolTip It displays the text when mouse is over the control.
• < input id="CheckBox2" type="checkbox" name="Ch
eckBox2" /><label for="CheckBox2">J2EE</label> Visible To set visibility of control on the form.

• This control has its own properties that are tabled Height It is used to set height of the control.
below.
Width It is used to set width of the control.

Checked It is used to set check state of the control either true or


false.
HTML Control: These controls render by the browser. We can also make HTML controls as
server control.
Controls Name Description
Button It is used to create HTML button.
Reset Button Resets all other HTML form elements on a form to a default value

Submit Button Automatically POSTs the form data to the specified page listed in the Action attribute in the FORM tag

Text Field Gives the user an input area on an HTML form


Text Area Used for multi-line input on an HTML form
File Field Places a text field and a Browse button on a form and allows the user to select a file name from their local
machine when the Browse button is clicked

Password Field An input area on an HTML form, although any characters typed into this field are displayed as asterisks

CheckBox Gives the user a check box that they can select or clear
Radio Button Used two or more to a form, and allows the user to choose one of the controls

Table Allows you to present information in a tabular format


Image Displays an image on an HTML form
ListBox Displays a list of items to the user. You can set the size from two or more to specify how many items you
wish show. If there are more items than will fit within this limit, a scroll bar is automatically added to this
control.

Dropdown Displays a list of items to the user, but only one item at a time will appear. The user can click a down arrow
from the side of this control and a list of items will be displayed.

Horizontal Rule Displays a horizontal line across the HTML page


ASP.NET - Managing State
There needs to be some technique to store the information between
requests and to retrieve it when required. This information i.e., the
current value of all the controls and variables for the current user in the
current session is called the State.

ASP.NET manages four types of states:


View State
Control State
Session State
Application State
View State
• The view state is the state of the page and all its controls. It is automatically
maintained across posts by the ASP.NET framework.
• When a page is sent back to the client, the changes in the properties of the page
and its controls are determined, and stored in the value of a hidden input field
named _VIEWSTATE. When the page is again posted back, the _VIEWSTATE field
is sent to the server with the HTTP request.
• The view state could be enabled or disabled for:
• The entire application by setting the EnableViewState property in the <pages>
section of web.config file.
• A page by setting the EnableViewState attribute of the Page directive, as <%@
Page Language="C#" EnableViewState="false" %>
• A control by setting the Control.EnableViewState property.
• It is implemented using a view state object defined by the StateBag class which
defines a collection of view state items. The state bag is a data structure
containing attribute value pairs, stored as strings associated with objects.
Control State
Control state cannot be modified, accessed directly, or disabled.

Session State
• When a user connects to an ASP.NET website, a new session object is
created. When session state is turned on, a new session state object is
created for each new request. This session state object becomes part of
the context and it is available through the page.
• Session state is generally used for storing application data such as
inventory, supplier list, customer record, or shopping cart. It can also keep
information about the user and his preferences, and keep the track of
pending operations.
• Sessions are identified and tracked with a 120-bit SessionID, which is
passed from client to server and back as cookie or a modified URL. The
SessionID is globally unique and random.
• The session state object is created from the HttpSessionState class, which
defines a collection of session state items.
Application State
• The ASP.NET application is the collection of all web pages, code and
other files within a single virtual directory on a web server. When
information is stored in application state, it is available to all the
users.
• To provide for the use of application state, ASP.NET creates an
application state object for each application from the
HTTPApplicationState class and stores this object in server memory.
This object is represented by class file global.asax.
• Application State is mostly used to store hit counters and other
statistical data, global application data like tax rate, discount rate etc.
and to keep the track of users visiting the site.

Potrebbero piacerti anche