0% found this document useful (0 votes)
61 views10 pages

Unit 1

ASP.NET is a web framework developed by Microsoft for building dynamic websites, web applications, and web services, first released in January 2002. It is built on the Common Language Runtime (CLR) and supports multiple programming languages, offering features like state management, caching, and security. The framework has evolved through various versions, with ASP.NET Core being its latest iteration, emphasizing modularity and cross-platform support.

Uploaded by

laita nikam
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
61 views10 pages

Unit 1

ASP.NET is a web framework developed by Microsoft for building dynamic websites, web applications, and web services, first released in January 2002. It is built on the Common Language Runtime (CLR) and supports multiple programming languages, offering features like state management, caching, and security. The framework has evolved through various versions, with ASP.NET Core being its latest iteration, emphasizing modularity and cross-platform support.

Uploaded by

laita nikam
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

Unit – 1 Introduction to 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 was first
released in January 2002. It is built on the Common Language Runtime (CLR) and allows programmers
to write code using any supported .NET language.

ASP.NET is a web application framework designed and developed by Microsoft. ASP.NET is open source
and a subset of the .NET Framework and successor of the classic ASP(Active Server Pages). With version
1.0 of the .NET Framework, it was first released in January 2002. So a question comes to mind that
which technology we were using before the year 2002 for developing web applications and services?
Answer is Classic ASP. So before .NET and ASP.NET there was Classic ASP.

ASP.NET is built on the CLR(Common Language Runtime) which allows the programmers to execute its
code using any .NET language(C#, VB etc.). It is specially designed to work with HTTP and for web
developers to create dynamic web pages, web applications, web sites, and web services as it provides a
good integration of HTML, CSS, and JavaScript.

.NET Framework is used to create a variety of applications and services like Console, Web, and Windows,
etc. But ASP.NET is only used to create web applications and web services. That’s why we termed
ASP.NET a

What is 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. The most recent version of ASP.Net is version 4.6. 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.

s a subset of the .NET Framework.

Components of ASP.NET:

It mainly contains three components:

1] Language: It contains a variety of languages such as VB.NET, C#, F#. These are used to develop web
applications.

2] Library: It contains a set of libraries. The most common library is the Web Library. Web Library
contains all the necessary components which are required for the development of web applications.

Framework Class Library (FCL) also called as Base Class Library. Following are the applications which
can make use of this library:
• Console Applications

• Windows Applications

• Web Applications

• Windows Services

• XML Web Services

3] Common Language Runtime (CLR):.NET programs are executed on Common Language Interface (CLI)
platform. CLR is responsible for performing activities like Exception Handling and Garbage Collection.

Language compilers convert the code language to Microsoft Intermediate Language (MSIL), which is then
converted to native code by CLR.

There are over 15 language compilers that execute under CLR.

Characteristics of ASP.NET:

• Code Behind Mode: This concept separates the design and code of an application. Due to this
separation, it becomes easy to maintain the application. Suppose we have a page called
Student.aspx. There is also another file Student. aspx.cs, which denotes the code part. So Visual
Studio creates a separate file for each page.

• State Management: HTTP is a stateless protocol. State management can be controlled with the
help of this protocol. Suppose in a shopping cart application, a user, after deciding what to buy,
clicks on the Submit button. The application remembers the item which the user has chosen. This
is remembering the state of an application.

• Caching: Caching improves the performance of an application. This concept caches those pages
which are frequently requested by the user, and this can be stored in a temporary location. Thus
pages can be retrieved faster and better responses can be sent to the user.

Static websites (without ASP.NET)


You've already seen such a website somewhere, for sure. HTML pages are simply stored on the server.
Once the client (the user with the browser) sends a request to the server, the server simply returns
those pages that it has stored.

Visually, the communication looks like this:

Dynamic websites (with ASP.NET)


The static websites are difficult to maintain and have great limitations. That's why server languages were
created, allowing the HTML page to be modified even before it's sent to the client. Like that, you can
create active elements such as discussion forums, user accounts, content management systems, and so
on.So ASP.NET runs on the server-side, it generates a website according to the request from the client
and sends it to the client. They see only the resulting HTML, where is no sign of ASP.NET (except that
the website has the .aspx extension and not .htmt).

There are enormous differences between C# and competing PHP. While PHP is a dynamic language, C#
is strongly typed. As it turned out, such a language can be also useful for the web, but if you come from
PHP, it may be unusual. The great advantage is the possibility to use the .NET framework that can be
helpful on the server-side because it contains many useful libraries and functions. Just to clarify, ASP.NET
is one of the .NET framework components.

ASP.NET runs on the IIS server (Internet Information Services) and can theoretically run even on the
Apache web server as a module (like PHP). We'll get this server installed with the full version of Visual
Studio or the free Visual Studio community version so we can simply debug websites on our computer

Features of Asp.Net
1. High Performance

Performance is always a critical feature for any of the applications or software. Due to its ASP.NET Core
and Kestrel web server, it’s remarked as the fastest and quick web application framework which is
available in the market. Due to its new Kestrel web server, it is more fast and lightweight. Also, it has
the advantage of asynchronous programming models. All other things like python, java, jsp, php use an
interpreter. However, compilers are faster as compared to the interpreter. Compilers take all the code
and compile at a time. So it is fast because ASP.NET uses compiler-based technology.

2. Cross-Platform and Container Support

As we say it supports cross-platform means it supports Windows, macOS, and Linux. So if we create
ASP.NET application then we can directly deploy it on these platforms.

3. Asynchronous via Async/Await

Asynchronous programming patterns is now implemented in all .net frameworks classes and 3 rd party
libraries. You know why asp.net is faster, because of its wide use of asynchronous patterns in kestrel
frameworks. However, most of the applications spend their lots of time waiting for database queries,
web services call and its input-output operations to complete.

Popular Course in this category

4. Rich Development Environments

If we are creating the application then we will use IDE i.e visual studio. It provides a rich development
environment by which we can easily drag and drop the components (radio buttons, checkboxes, etc.)
and create the application.
5. Language Independent

The framework is language independent that is developers can use various languages like C#. So it’s
easy for a developer to make its application by language which they know. We can create a dynamic
web application using any of the languages.

6. Supports for Web Sockets

Sockets are used to create a client – server-based Applications. By socket normally we can create web-
based client-server applications. These provide back and forth communication of the browser.

7. Action Filters

NET supports a very great feature that is ACTION FILTERS. These filters are used to implement error
handling, authorization, caching or to any custom logic which we would like to implement. There is a
logic been implemented which will be executed before and after controller action. To implement these
logic Action filters are used.

8. Globalization and Localization

We host the web application and it can be accessed from anywhere globally. So language, date and time
format, number format, the currency must be different for different regions or countries. ASP.NET
supports globalization so that different countries’ clients or people also can understand and they can
access this application. ASP.NET customize our application for different languages with the help of
resource files. These files act as a central repository where all the texts are placed.

9. Security

As it supports the .net framework so it will provide security for our application. Applications have its
individual identity, so before running this .net will check its identity of those objects. It will also check
the operating system security. Due to its pre-application configuration and feature of built-in windows
authentication, our developed application is safe and secure. With built-in Windows authentication and
per-application configuration, your applications are safe and secured.

10. Supports for HTML5 Form Types

It provides support for HTML5 form types. There the new controls are available in HTML5 like email, URL,
Number, RNGE, Date pickers (week, date, month, time, DateTime-local, etc.), color and search.

11. NET Web API

This includes ASP.NET web forms. HTTP services are easily consumed and build with the help of
ASP.NET Web API.

History of ASP.NET
ASP.NET is an open-source, server-side web-application framework designed for web development to
produce dynamic web pages. It was developed by Microsoft to allow programmers to build dynamic web
sites, applications and services.

It was first released in January 2002 with version 1.0 of the .NET Framework and is the successor to
Microsoft's Active Server Pages (ASP) technology. ASP.NET is built on the Common Language
Runtime (CLR), allowing programmers to write ASP.NET code using any supported .NET language. The
ASP.NET SOAP extension framework allows ASP.NET components to process SOAP messages.

The January 5, 2002 release of ASP.NET 1.0 was preceded by four years of development, and multiple
beta releases in 2000 and 2001. These beta releases led to dozens of books being written about ASP.NET
before version 1.0 even came out.
After it’s release it was promoted heavily by Microsoft, which put Scott Guthrie in charge of further
development of the framework. He oversaw the April 24, 2003 release of ASP.NET 1.1, which improved
support for mobile clients.

ASP.NET was succeeded by ASP.NET Core. It makes the framework modular in nature, designed to be
used alongside technologies like the Entity Framework. This move brings ASP.NET MVC, ASP.NET Web
API, and ASP.NET Web Pages together under the umbrella of ASP.NET Core.

ASP.NET Versions History

The following table shows the versions and features included in ASP.NET.

Date Version Features

January 16, 2002 1.0 Object-oriented Web application development supporting


inheritance, polymorphism and other standard OOP
features.

April 24, 2003 1.1 Mobile controls and Automatic input validation.

November 7, 2005 2.0 New data controls (GridView, FormView, DetailsView), New
technique for declarative data access (SqlDataSource,
ObjectDataSource, XmlDataSource controls), Navigation controls
Master pages ,Login controls, Themes ,Skins, Web parts
Personalization services ,Full pre-compilation, New localization
technique ,Support for 64-bit processors, Provider class model
November 21, 3.0 Windows Presentation Foundation (WPF)
2006 Windows Workflow Foundation (WF)
Windows Communication Foundation, which can use
ASP.NET to host services
Windows CardSpace, which uses ASP.NET for login roles

November 19, 3.5 New data controls (ListView, DataPager)


2007 ASP.NET AJAX included as part of the framework
Support for HTTP pipelining and syndication feeds.
WCF support for RSS, JSON, POX and Partial Trust
All the .NET Framework 3.5 changes, like LINQ etc.

August 11, 2008 3.5 Service Incorporation of ASP.NET Dynamic Data


Pack1 Support for controlling browser history in an ASP.NET AJAX
application
Ability to combine multiple JavaScript files into one file for
more efficient downloading
New namespaces System.Web.Abstractions and
System.Web.Routing

April 12, 2010 4.0 The two new properties added in the Page class are
MetaKeyword and MetaDescription.

August 15, 2012 4.5

October 17, 2013 4.5.1 Bootstrap 3.0


Web API 2: OAuth 2.0, OData improvements, CORS
MVC 5: Attribute routing, authentication filters and filter
overrides
EF 6
SignalR
OWIN

May 5, 2014 4.5.2 Higher reliability HTTP header inspection and modification
methods
New way to schedule background asynchronous worker
tasks

July 20, 2015 4.6 HTTP/2 support when running on Windows 10


More async task-returning APIs

Structure of Asp.Net Page


The Structure of an ASP.NET Page

You are now in a position to examine the formal structure of an ASP.NET page. The following is a list of
the important elements of an ASP.NET page:

• Directives

• Code declaration blocks

• ASP.NET controls

• Code render blocks

• Server-side comments

• Server-side include directives

Each element is discussed in the following sections.

DIRECTIVES
A directive controls how an ASP.NET page is compiled. The beginning of a directive is marked with the
characters <%@ and the end of a directive is marked with the characters %>. A directive can appear
anywhere within a page. By convention, however, a directive typically appears at the top of an ASP.NET
page.
There are several types of directives that you can add to an ASP.NET page. Two of the most useful types
are page and import directives.

P AGE D IRECTIVES
You can use a page directive to specify the default programming language for a page. Page directives
can also be used to enable tracing and debugging for a page.To change the default programming
language of an ASP.NET page from Visual Basic to C#, for example, you would use the following page
directive: <%@Page Language=”c#”%>

Import Directives

By default, only certain namespaces are automatically imported into an ASP.NET page. If you want to
refer to a class that isn't a member of one of the default namespaces, then you must explicitly import
the namespace of the class or you must use the fully qualified name of the class.
For example, suppose that you want to send an email from an ASP.NET page by using the Send method
of the SmtpMail class. The SmtpMail class is contained in the System.Web.Mail namespace. This is not
one of the default namespaces imported into an ASP.NET page.

The easiest way to use the SmtpMail class is to add an Import directive to your ASP.NET page to import
the necessary namespace. The page in Listing 12 illustrates how to import
the System.Web.Mail namespace and send an email message.

ASP.NET Controls

ASP.NET controls can be freely interspersed with the text and HTML content of a page. The only
requirement is that the controls should appear within a <form Runat="Server"> tag. And, for certain
tags such as <span Runat="Server"> and <ASP:Label Runat="Server"/>, this requirement can be
ignored without any dire consequences.

One significant limitation of ASP.NET pages is that they can contain only one <form
Runat="Server"> tag. This means that you cannot group ASP.NET into multiple forms on a page. If you
try, you get an error.

Code Render Blocks

If you need to execute code within the HTML or text content of your ASP.NET page, you can do so
within code render blocks. The two types of code render blocks are inline code and inline expressions.
Inline code executes a statement or series of statements. This type of code begins with the
characters <% and ends with the characters %>.

Inline expressions, on the other hand, display the value of a variable or method (this type of code is
shorthand for Response.Write). Inline expressions begin with the characters <%= and end with the
characters %>.

Server-side Comments

You can add comments to your ASP.NET pages by using server-side comment blocks. The beginning of
a server-side comment is marked with the characters <%-- and the end of the comment is marked with
the characters --%>.

Server-side comments can be added to a page for the purposes of documentation. Note that you cannot
see the contents of server-side comment tags, unlike normal HTML comment tags, by using the View
Source command on your Web browser.

Server-side Include Directives

You can include a file in an ASP.NET page by using one of the two forms of the server-side include
directive. If you want to include a file that is located in the same directory or in a subdirectory of the
page including the file, you would use the following directive:

<!-- #INCLUDE file="includefile.aspx" -->

Alternatively, you can include a file by supplying the full virtual path. For example, if you have a
subdirectory named myDirectory under the wwwroot directory, you can include a file from that directory
like this:

<!-- #INCLUDE virtual="/myDirectory/includefile.aspx" -->

The include directive is executed before any of the code in a page. One implication is that you cannot
use variables to specify the path to the file that you want to include. For example, the following directive
would generate an error:
ASP.NET Web Pages Model(Single Page Model, Two Page Model)

WHAT IS ASP.NET WEB PAGES?


ASP.NET Web Pages is a simplified framework that we can use to build ASP.NET content quickly and
easily. It is one of the three programming models for creating ASP.NET web sites and web applications.
The other two programming models are Web Forms and MVC.

Web Pages is one of the 3 programming models for creating ASP.NET web sites and web applications.

The other two programming models are Web Forms and MVC (Model, View, Controller).

Web Pages is the simplest programming model for developing ASP.NET web pages. It provides an easy
way to combine HTML, CSS, JavaScript and server code:

• Easy to learn, understand, and use

• Built around single web pages

• Similar to PHP and Classic ASP

• Server scripting with Visual Basic or C#

• Full HTML, CSS, and JavaScript control

Web Pages is easy extendable with programmable Web Helpers, including database, video, graphics,
social networking and much more.

ASP.NET Web Page Code Model

An ASP.NET Web page consists of two parts:

• Visual elements, which include markup, server controls, and static text.
• Programming logic for the page, which includes event handlers and other code.

ASP.NET provides two models for managing the visual elements and code — the single-file page model
and the code-behind page model. The two models function the same, and you can use the same
controls and code for both models.

This topic explains how each model functions and provides suggestions for when to choose one model
or the other.

The Single-File Page Model


In the single-file page model, the page's markup and its programming code are in the same physical
.aspx file. The programming code is in a script block that contains the attribute runat="server" to mark
it as code that ASP.NET should execute.

The following code example shows a single-file page containing a Button control and a Label control.
The highlighted portion shows the Click event handler for the Button control inside a script block.

The scriptblock can contain as much code as the page requires. The code can consist of event handlers
for controls on the page (as in the example), methods, properties, and any other code that you would
normally use in a class file. At run time, a single-file page is treated as a class that derives from
the Page class. The page does not contain an explicit class declaration. Instead, the compiler generates
a new class that contains the controls as members. (Not all controls are exposed as page members;
some are children of other controls.) The code in the page becomes part of the class; for example,
event handlers that you create become members of the derived Page class.
Because all code in the page becomes members of the Page class, you cannot have a using statement
in your code. Instead, add a @ Import directive that specifies the namespace to import. You might also
need to add a reference to the DLL that contains the namespace.

Life Cycle of ASP.NET


-The ASP.NET Life Cycle is very crucial to develop applications. It includes various stages that help to
produce dynamic output.

The Life Cycle of ASP.NET is divided into two categories:

1. Application Life Cycle

2. Page Life Cycle

Application Life Cycle


The Application Life Cycle has the following steps:

1. Application Start
The webserver executes the application start when a user requests an application for access. In this
method, it sets all global variables to default.

2. Object Creation
Object creation holds all the HTTP Context, HTTP Request, and HTTP Response by the webserver. It
also contains information about the request, cookies, and browsing information.

3. HTTP Application
HTTP Application is an object created by the webserver. It helps to process all the subsequent
information that is sent to the user.

4. Dispose
Dispose is an event that is called before the application is destroyed. It also helps to release manually
unmanaged resources when the objects are no longer needed.

5. Application End
Application End is the last stage of the application life cycle. It helps to unload the memory.
Page Life Cycle

The Page Life Cycle has certain phases that help in writing custom controls and initializing an
application.
Following are the different phases of the Page Life Cycle:
1. Page Request
Page Request is the first step of the page life cycle. When a user request is made, then the server
checks the request and compiles the pages. Once the compilation is done, then the request is sent
back to the user.

2. Page Start
Page Start helps in creating two objects: Request and response. The Request holds all the information
which the user sent. While the response contains all the information that is sent back to the user.

3. Page Initialization
Page Initialization helps to set all the controls on the pages. It has a separate ID, and it applies themes
to the pages in this step.

4. Page Load
Page Load helps to load all the control properties of an application. It also helps to provide information
using view state and control state.

5. Validation
Validation happens when the execution of an application is successful. It returns two conditions: true
and false. If execution is successful, it returns true, otherwise false.

6. Event Handling
Event Handling takes place when the same pages are loaded. It is a response for the validation. When
the same page is loaded, a Postback event is called, which checks the page’s credentials.

7. Rendering
Rendering happens before it sends all the information back to the user. And all this information is
stored before being sent back.

8. Unload
Unload is a process that helps in deleting all unwanted information from the memory once the output is
sent to the user.

What is ASP.NET? Explain features of ASP.NET?


Write the short notes on following page directives. Page ii) Register .iii) Import iv) Assembly
Write short notes on ASP.NET page life cycle

You might also like