Unit 1. Introduction to .NET Framework and ASP.
NET
1.1 Introduction to. NET Framework
What is .Net Framework?
.Net Framework is a software development platform developed by
Microsoft for building and running Windows applications. The .Net
framework consists of developer tools, programming languages, and
libraries to build desktop and web applications. It is also used to build
websites, web services, and games.
The .Net framework was meant to create applications, which would run
on the Windows Platform. The first version of the .Net framework was
released in the year 2002. The version was called .Net framework 1.0.
The Microsoft .Net framework has come a long way since then, and the
current version is .Net Framework 4.8.1
The framework includes a variety of programming languages, such
as C#, F#, and Visual Basic, and supports a range of application types,
including desktop, web, mobile, and gaming applications.
1. The .NET Framework includes two main components: the
Common Language Runtime (CLR) and the .NET Framework
Class Library. The CLR is responsible for managing the
execution of code written in any of the supported languages,
while the class library provides a large set of pre-built
functions and classes that can be used to create a wide range of
applications.
2. One of the key advantages of the .NET Framework is its
support for a variety of programming languages. This means
that developers can choose the language that best fits their
needs and expertise, while still being able to use the same set
of libraries and tools provided by the framework.
3. Another advantage of the .NET Framework is its support for a
variety of application types. The framework includes libraries
and tools for creating desktop, web, mobile, and gaming
applications, which makes it a versatile choice for developers
working on a wide range of projects.
4. The .NET Framework also provides a number of features that
help improve the security, reliability, and performance of
applications. These include features such as code access
security, automatic memory management, and just-in-time (JIT)
compilation, which helps improve the speed of application
execution.
5. The .NET Framework is also designed to integrate with other
Microsoft technologies, such as Microsoft SQL Server,
Microsoft SharePoint, and Microsoft Office, which can make it
easier to build applications that work seamlessly with other
Microsoft products.
Overall, the .NET Framework is a powerful and versatile development
platform that provides a wide range of tools and libraries for building
and running applications on Windows operating systems.
The Microsoft .Net framework can be used to create both
– Form-based and Web-based applications. Web services can also be
developed using the .Net framework.
The framework also supports various programming languages such as
Visual Basic and C#. So developers can choose and select the language to
develop the required application.
1.2 .Net framework Architecture
.NET Framework is a software development framework for building
and running applications on Windows.
.NET Framework is part of the .NET platform, a collection of
technologies for building apps for Linux, macOS, Windows, iOS,
Android, and more.
The .NET Framework architecture is a comprehensive platform
developed by Microsoft for building and running various types of
applications, including Windows desktop applications, web applications,
and services. While .NET Framework has been succeeded by .NET Core
(now known as .NET 5+), it's still essential to understand its architecture
for historical context and maintaining legacy applications. Below is an
overview of the .NET Framework architecture:
Common Language Runtime (CLR):
At the core of the .NET Framework is the Common Language Runtime
(CLR). It's responsible for managing the execution of .NET applications.
CLR provides services like memory management (garbage collection),
exception handling, security, and thread management.
It compiles source code into Intermediate Language (IL) code and then
Just-In-Time (JIT) compiles it into machine code for execution.
Class Library:
.NET Framework includes a vast class library known as the Base Class
Library (BCL) or Framework Class Library (FCL).
The BCL provides a collection of pre-defined classes and APIs for
performing common tasks, such as file I/O, networking, data access, and
more.
Languages:
.NET Framework supports multiple programming languages, including
C#, [Link], F#, and others.
Developers can write code in their preferred language, thanks to the
Common Intermediate Language (CIL) to which all .NET languages
compile.
Assemblies:
Assemblies are the fundamental units of deployment and versioning in
the .NET Framework.
An assembly can be a single .exe or .dll file containing one or more
managed modules.
Assemblies contain metadata, manifest information, and IL code.
Base Class Library (BCL):
The BCL consists of classes and libraries that provide essential
functionality for applications, including data access, XML processing,
file handling, and more.
Developers can use these libraries to avoid reinventing common
functionality.
Application Domains:
Application Domains (AppDomains) provide isolation between
multiple .NET applications running within the same process.
They help in ensuring that an issue in one application doesn't affect others
within the same process.
Security:
.NET Framework includes a robust security model that incorporates code
access security (CAS), role-based security, and authentication
mechanisms to protect applications from unauthorized access and
malicious code.
Garbage Collection (GC):
The GC subsystem automatically manages memory by reclaiming
memory that is no longer in use.
This prevents memory leaks and helps ensure efficient memory usage
in .NET applications.
Interop Services:
.NET Framework allows interoperability with existing native code
libraries through Platform Invocation Services (P/Invoke) and COM
Interop.
Windows Forms (WinForms) and [Link]:
.NET Framework includes libraries for building both Windows desktop
applications (WinForms) and web applications ([Link] Web Forms
and [Link] MVC).
[Link]:
[Link] provides a set of classes for data access and manipulation,
allowing .NET applications to interact with various data sources,
including databases.
WCF, WF, and WPF:
.NET Framework includes additional technologies like Windows
Communication Foundation (WCF) for building distributed services,
Windows Workflow Foundation (WF) for workflow-based applications,
and Windows Presentation Foundation (WPF) for building rich desktop
applications.
Visual Studio:
Developers typically use Microsoft Visual Studio as the Integrated
Development Environment (IDE) for building .NET Framework
applications.
Please note that the .NET Framework has largely been replaced by .NET
5+ (now .NET 6+), which is a more modern, cross-platform framework.
If you are starting new development projects, it's recommended to use the
latest .NET versions, but understanding the .NET Framework architecture
is still valuable for maintaining existing applications.
1.3 Net Framework components(CLR, CLS, CTS,
JIT)
There are following components of .NET Framework:
1. CLR (Common Language Runtime)
2. CTS (Common Type System)
3. BCL (Base Class Library)
4. CLS (Common Language Specification)
5. FCL (Framework Class Library)
6. .NET Assemblies
7. XML Web Services
8. Window Services
CLR (common language runtime)
It is an important part of a .NET framework that works like a virtual
component of the .NET Framework to executes the different languages
program like c#, Visual Basic, etc. A CLR also helps to convert a source
code into the byte code, and this byte code is known as CIL (Common
Intermediate Language) or MSIL (Microsoft Intermediate Language).
After converting into a byte code, a CLR uses a JIT compiler at run time
that helps to convert a CIL or MSIL code into the machine or native code.
JIT (Just-in-Time)
Just - in - Time (JIT) compiler, which compiles MSIL into native code
that is specific to the OS and machine architecture being targeted. Only at
this point can the OS execute the application. The just - in - time part of
the name reflects the fact that MSIL code is only compiled as, and when,
it is needed.
CTS (Common Type System)
It specifies a standard that represent what type of data and value can be
defined and managed in computer memory at runtime. A CTS ensures
that programming data defined in various languages should be interact
with each other to share information. For example, in C# we define data
type as int, while in [Link] we define integer as a data type.
BCL (Base Class Library)
The base class library has a rich collection of libraries features and
functions that help to implement many programming languages in
the .NET Framework, such as C #, F #, Visual C ++, and more.
Furthermore, BCL divides into two parts:
1. User defined class library
o Assemblies - It is the collection of small parts of deployment
an application's part. It contains either the DLL (Dynamic
Link Library) or exe (Executable) file.
1. In LL, it uses code reusability, whereas in exe it
contains only output file/ or application.
2. DLL file can't be open, whereas exe file can be open.
3. DLL file can't be run individually, whereas in exe, it
can run individually.
4. In DLL file, there is no main method, whereas exe file
has main method.
2. Predefined class library
o Namespace - It is the collection of predefined class and
method that present in .Net. In other languages such as, C we
used header files, in java we used package similarly we used
"using system" in .NET, where using is a keyword and
system is a namespace.
CLS (Common language Specification)
It is a subset of common type system (CTS) that defines a set of rules and
regulations which should be followed by every language that comes
under the .net framework. In other words, a CLS language should be
cross-language integration or interoperability. For example, in C# and
[Link] language, the C# language terminate each statement with
semicolon, whereas in [Link] it is not end with semicolon, and when
these statements execute in .NET Framework, it provides a common
platform to interact and share information with each other.
Microsoft .NET Assemblies
A .NET assembly is the main building block of the .NET Framework. It
is a small unit of code that contains a logical compiled code in the
Common Language infrastructure (CLI), which is used for deployment,
security and versioning. It defines in two parts (process) DLL and library
(exe) assemblies. When the .NET program is compiled, it generates a
metadata with Microsoft Intermediate Language, which is stored in a file
called Assembly.
FCL (Framework Class Library)
It provides the various system functionality in the .NET Framework, that
includes classes, interfaces and data types, etc. to create multiple
functions and different types of application such as desktop, web, mobile
application, etc. In other words, it can be defined as, it provides a base on
which various applications, controls and components are built in .NET
Framework.
1.4 Features of [Link]
1. High Performance
Performance is always a critical feature for any of the applications or
software. Due to its [Link] 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 [Link] uses compiler-based technology.
An asynchronous model allows multiple things to happen at the same
time. When you start an action, your program continues to run.
When the action finishes, the program is informed and gets access to
the result (for example, the data read from disk).
2. Cross-Platform and Container Support
As we say it supports cross-platform means it supports Windows, macOS,
and Linux. So if we create [Link] application then we can directly
deploy it on these platforms.
3. Rich Development Environments
If we are creating the application then we will use IDE (integrated
development environment )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.
4. 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.
5. 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.
6. 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.
7. 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.
[Link] supports globalization so that different countries’ clients or
people also can understand and they can access this application.
[Link] 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 [Link] web forms. HTTP services are easily consumed
and build with the help of [Link] Web API.
1.5 Differences between [Link] and ASP
ASP stands for Active Server Pages. It is a development framework
used for building web pages. ASP was introduced in 1998 by Microsoft
as its first server-side scripting language. The file extension of ASP
pages are .asp and are normally written in VBScript. It is an old but still
powerful tool for making dynamic web pages. ASP is a technology
(much like PHP) for executing scripts on a web server.
[Link]: [Link] was released in 2002 by Microsoft as a successor
to ASP. It is also a server-side web framework, open-source, which is
designed for the generation of dynamic web pages. The file extension of
[Link] pages is .aspx and is normally written in C# (C sharp). The
latest version of [Link] is [Link] 4.6.
Difference between ASP and [Link]:
ASP [Link]
[Link] is the compiled
ASP is the interpreted language.
language.
ASP uses ADO (ActiveX Data [Link] uses [Link] to
Objects) technology to connect and connect and work with
ASP [Link]
work with databases. databases.
[Link] is fully
ASP is partially object-oriented.
object-oriented.
In ASP there is no facility to separate In [Link] it has the option of
design from programming logic. Code Containment.
ASP Pages have the file [Link] Pages have the file
extension .asp. extension .aspx.
ASP doesn’t have the concept of [Link] inherit the class
inheritance. written in code behind.
[Link] uses a full-fledged
ASP pages use scripting language.
programming language.
Error handling is very good in
Error handling is very poor in ASP.
[Link].
In ASP debugging is difficult because
In [Link] debugging is easy.
the ASP scripts are interpreted.
In [Link] [Link] is
ASP is not a configurable language.
used for configuration.
ASP has maximum four in-built
[Link] has more than 2000
classes i.e. Request, Response,
in-built classes.
Session and Application.
Custom Controls can be
Custom Controls can not be achieved
achieved by [Link] using
by ASP.
@register directive.
1.6 Client Server Architecture
The Client-server model is a distributed application structure that
partitions task or workload between the providers of a resource or
service, called servers, and service requesters called clients. In the
client-server architecture, when the client computer sends a request for
data to the server through the internet, the server accepts the requested
process and deliver the data packets requested back to the client. Clients
do not share any of their resources. Examples of Client-Server Model
are Email, World Wide Web, etc.
How the Client-Server Model works ?
Client: When we talk the word Client, it mean to talk of a person
or an organization using a particular service. Similarly in the digital
world a Client is a computer (Host) i.e. capable of receiving
information or using a particular service from the service providers
(Servers).
Servers: Similarly, when we talk the word Servers, It mean a
person or medium that serves something. Similarly in this digital
world a Server is a remote computer which provides information
(data) or access to particular services.
So, its basically the Client requesting something and the Server serving
it as long as its present in the database.
How the browser interacts with the servers ?
There are few steps to follow to interacts with the servers a client.
User enters the URL(Uniform Resource Locator) of the website or
file. The Browser then requests the DNS(DOMAIN NAME SYSTEM)
Server.
DNS Server lookup for the address of the WEB Server.
DNS Server responds with the IP address of the WEB Server.
Browser sends over an HTTP/HTTPS request to WEB Server’s
IP (provided by DNS server).
Server sends over the necessary files of the website.
Browser then renders the files and the website is displayed. This
rendering is done with the help of DOM (Document Object Model)
interpreter, CSS interpreter and JS Engine collectively known as
the JIT or (Just in Time) Compilers.
Advantages of Client-Server model:
Centralized system with all data in a single place.
Cost efficient requires less maintenance cost and Data recovery is
possible.
The capacity of the Client and Servers can be changed separately.
Disadvantages of Client-Server model:
Clients are prone to viruses, Trojans and worms if present in the
Server or uploaded into the Server.
Server are prone to Denial of Service (DOS) attacks.
Data packets may be spoofed or modified during transmission.
Phishing or capturing login credentials or other useful information
of the user are common and MITM(Man in the Middle) attacks are
common.