Introduction .NET
Server-side Programming
Code executes on the server.
When the code finished executing , the user receives
the HTML page , which can be viewed in any browser
ASP. NET code
ASP code
Client-side Programming
Don’t involve any server processing
Complete application is downloaded to the client
browser ,which executes it locally.
They aren’t supported by all browsers and operating
systems
Java script, ActiveX, Java, Flash etc
Compilation in .NET
Code in VB.NET
Code in C#
Code in another
.NET Language
VB.NET compiler
C# compiler
Appropriate
Compiler
IL(Intermediate
Language) code
Dll or exe files
CLR just-in-time
Execution [JIT]
Native Machine Code
Execute
Language compilation in .NET
.NET FRAMEWORK
.NET framework is a cluster of several technologies:
1).Net language
VB,C#,C++ etc
Languages provided by MS
VB, C++, C#, J#, JScript
Third-parties are building
APL, COBOL, Pascal, Eiffel, Haskell, ML, Oberon, Perl, Python,
Scheme, Smalltalk
Framework, Languages, And Tools
VB
VC++
VC#
…
JScript
Common Language Specification
Windows
Forms
ADO.NET: Data and XML
Base Class Library
Common Language Runtime
Visual Studio.NET
ASP.NET: Web Services
and Web Forms
2) Common Language Runtime(CLR)
The Common Language Runtime (CLR) is an Execution Environment .
It works as a layer between Operating Systems and the applications written
in .Net languages that conforms to the Common Language Specification
(CLS), which is a standard type system used by all .Net languages .
The main function of Common Language Runtime (CLR) is to convert the
Managed Code [IL] into native code and then execute the Program.
The Managed Code compiled only when it needed, that is it converts the
appropriate instructions when each function is called .
The Common Language Runtime (CLR) 's Just In Time (JIT) compilation
converts Intermediate Language (MSIL) to native code on demand at
application run time.
Diagram
Common Language Runtime (CLR)
CLR works like a virtual machine in executing all languages.
All .NET languages must obey the rules and standards imposed by CLR.
Examples:
Object declaration, creation and use
Data types, language libraries
Error and exception handling
Interactive Development Environment (IDE)
Common Language Runtime
Multiple Language Support
Mixed language applications
Common Language Specification (CLS)
• CLS is a set of specifications that language and library designers
need to follow
– This will ensure interoperability between languages
Common Type System (CTS)
• CTS is a rich type system built into the CLR which is a standard
type system used by all .Net languages .
– Implements various types (int, double, etc)
– And operations on those types
Functions of the CLR
Convert code into IL.
Exception handling
Type safety
Memory management (using the Garbage Collector)
Security
Improved performance
Language independency
Platform independency
Architecture independency
Components of the CLR
Class Loader
Used to load all classes at run time.
MSIL to Native code
The Just In Time (JTI) compiler will convert MSIL code into
native code.
Code Manager
It manages the code at run time.
Components of the CLR
Garbage Collector
It manages the memory. Collect all unused objects and deallocate
them to reduce memory.
Thread Support
It supports multithreading of our application.
Exception Handler
It handles exceptions at run time.
The implications of the CLR are wide ranging:
Deep Language Integration
Side by side execution
Fewer Error
Performance
Code transparency
Questionable Cross platform support
Intermediate Language
.NET languages are not compiled to machine code.
They are
compiled to an Intermediate Language (IL).
CLR accepts the IL code and recompiles it to machine code. The
recompilation is just-in-time (JIT) meaning it is done as soon as a
function or subroutine is called.
The JIT code stays in memory for subsequent calls. In cases where
there is not enough memory it is discarded thus making JIT process
interpretive.
Compilation in .NET
Code in VB.NET
Code in C#
Code in another
.NET Language
VB.NET compiler
C# compiler
Appropriate
Compiler
IL(Intermediate
Language) code
Dll or exe files
CLR just-in-time
Execution [JIT]
Native Machine Code
Execute
Language compilation in .NET
3).Net framework Class Library
Collects 1000’s of prebuilt functions
Ex:
ADO.NET(Creating Databases)
WPF(Windows Presentation Foundations)-creating desktop user
Interface
NET Framework Class Library
The .NET Framework class library is a library of classes,
interfaces, and value types that provide access to
system functionality.
It is the foundation on which .NET Framework
applications, components, and controls are built.
The .NET Class Library
The .NET class library is a giant repository of classes that
provide prefabricated functionality for everything from
reading an XML file to sending an e-mail message.
The namespaces and namespace categories in the class
library are listed in the following table
Namespace and its Description
System
The System namespace contains fundamental classes and base classes that
define commonly-used value and reference data types, events and event handlers,
interfaces, attributes, and processing exceptions.
System.Data
The System.Data namespaces contain classes for accessing and managing data
from diverse sources. The top-level namespace and a number of the child
namespaces together form the ADO.NET architecture and ADO.NET data
providers.
System.IO
The System.IO namespaces contain types that support input
and output, including the ability to read and write data to
streams either synchronously or asynchronously,
to compress data in streams,
to map files to an application's logical address space, to store
multiple data objects in a single container,
to communicate using anonymous or named pipes,
to implement custom logging, and to handle the flow of data
to and from serial ports.
System.Web – contains classes and interfaces that enable
browser/server communication. This namespace provides
classes
for
managing
HTTP
output
to
the
client
(HttpResponse) and reading HTTP requests (HttpRequest).
Additional classes provide facilities for server-side utilities
and processes, cookie manipulation, file transfer, exception
information, and output cache control.
System.Web.UI – contains classes for creating Web Form
pages, including the Page class and other standard
classes used to create Web user interfaces.
System.Web.UI.HtmlControls
–
contains
classes
for
HTML-specific controls that can be added to Web Forms
to create Web user interfaces.
System.Web.UI.WebControls
–
contains
classes for creating ASP.NET Web server
controls. When added to a Web Form, these
controls render browser-specific HTML and
script to create a device-independent Web user
interface.
4) ASP.NET :
Engine that hosts the web applications created with .NET
and
supports almost any features from the .NET frame work library.
ASP.NET also includes a set of web specific services, such as
secure authentication and data storage.
5) Visual Studio :
Development tool contains a rich set of productivity and debugging
features.
The HTML server controls are basically the standard
HTML controls enhanced to enable server side
processing.
The HTML controls such as the header tags, anchor tags,
and input elements are not processed by the server but
are sent to the browser for display.
By default, HTML elements on an ASP.NET Web page are
not available to the server. These components are treated
as simple text and pass through to the browser.
They are specifically converted to a server control by
adding the attribute runat="server" and adding an id
attribute to make them available for server side
processing.
For example, consider the HTML input control: It could be
converted to a server control, by adding the runat and id
attribute:
All the HTML Server controls can be accessed through the
Request object. The HTML server controls have the same
HTML output and the same properties as their
corresponding HTML tags.
In addition, HTML server controls provide automatic state
management and server-side events. HTML server controls
offer the following advantages:
• The HTML server controls map one to one with their
corresponding HTML tags. • When the ASP.NET application
is compiled, the HTML server controls with the runat=server
attribute are compiled into the assembly.