0% found this document useful (0 votes)
12 views

Unit 1

Awp notes

Uploaded by

ns1978314
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)
12 views

Unit 1

Awp notes

Uploaded by

ns1978314
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/ 87

Unit 1

Prof. Rohan kishor parab


prof. Rohan kishor parab
.NET frameworks

● .NET is a platform introduced by Microsoft to


develop, host, deploy, maintain and execute
applications.

● Using .NET the applications are developed using


prof. Rohan kishor parab

languages such as C#, VB.NET,J# and so on.

● More than 100 languages are supported by .NET


Framework.
What Is .NET

• .NET is a framework

⚫ New programming methodology

⚫ .NET is platform independent / cross platform

⚫ .NET is language-case sensitive


.NET is
cross-platform
APP.exe

?
Win64 Win32 WinCE
(XP,2K,98)
ASP Architecture
PC/Mac/Unix
Clie + Browser (IE, FireFox)
nt
Request:
http://www.msn.com/default.aspx

HTTP
Netwo TCP/IP
rk
Response:
<html>…</html>

Serv IIS
er (Internet Information Server)
Server-Side Code
What is server-side code?
Software that runs on the server, not
the client HTTP request
Receives input from (form data, HTTP response
URL parameters HTTP HTML, XML
HTML form data header data)
Can access server-side databases,
e-mail servers, files, mainframes, etc.
Dynamically builds a custom HTML
response ASP page
for a client (static HTML,
server-side
logic)
The code-behind file (WebTime.aspx.cs)

The Page_Init
method handles the
page’s Init event,
which indicates that
the page is ready to
be initialized.

Retrieve the current


time and formats it
as hh:mm:ss.

Code-behind file for a page that displays


the web server’s time. (Part 1 of 2.)
prof. Rohan kishor parab
OOPs with C#

1. ABSTRACTION

2. ENCAPSULATION

3. INHERITANCE
prof. Rohan kishor parab

4. POLYMORPHISM
ABSTRACTION

● Abstraction is "To represent the essential feature


without representing the background details.“
● Example:
– Consider the mobile example. Whenever you buy a
mobile phone, you see their different types of
functionalities as camera, mp3 player, calling function,
prof. Rohan kishor parab

recording function, multimedia etc. It is abstraction,


because you are seeing only relevant information
instead of their internal engineering.
● Abstraction is implemented using interface and
abstract class
CAR example for Abstraction

● Necessary things means compulsory to know


before starting a car
– 1. Name of Car
– 2. Color of Car
– 3. Steering
– 4. Rear View Mirror
prof. Rohan kishor parab

– 5. Brakes
– 6. Gear
● Unnecessary things means not that compulsory
to know for a Car rider
– 1. Internal Details of a Car
– 2. Car Engine
– 3. Diesel Engine
– 4. Exhaust System
prof. Rohan kishor parab

– 5. Silencer
ENCAPSULATION
● Encapsulation hides the information
● Encapsulation is implemented by using access
specifiers.
● An access specifier defines the scope and visibility of a
class member.
● C# supports the following access specifiers:
prof. Rohan kishor parab

– Public
– Private
– Protected
– Internal
– Protected internal
prof. Rohan kishor parab
● While encapsulation hides the internal
implementation of the functionalities of class
without affecting the overall functioning of the
system
● The following are the benefits of encapsulation:
prof. Rohan kishor parab

– Protection of data from accidental corruption


– Specification of the accessibility of each of the
members of a class to the code outside the class
– Flexibility and extensibility of the code and reduction
in complexity
prof. Rohan kishor parab
Inheritance

● Inheritance allows us to define a class in terms of


another class, which makes it easier to create
and maintain an application.
● This also provides an opportunity to reuse the
code functionality and fast implementation time.
prof. Rohan kishor parab

● When creating a class, instead of writing


completely new data members and member
functions, the programmer can designate that the
new class should inherit the members of an
existing class.
● This existing class is called the base class, and
the new class is referred to as the derived class.
● The idea of inheritance implements the IS-A
relationship.
● For example, mammal IS A animal, dog IS-A
prof. Rohan kishor parab

mammal hence dog IS-A animal as well and so


on.
POLYMORPHISM
● "Poly" means many and "morph" means forms
hence the name polymorphism.

● Polymorphism also referred to as one name many


forms or having one name with multiple
functionality.
prof. Rohan kishor parab

● In simple words you can use same method name


with different signature or same signature but in
different class.
● Polymorphism can be
– Static OR
– Dynamic

● In static polymorphism the response to a


prof. Rohan kishor parab

function is determined at the compile time.

● In dynamic polymorphism , it is decided at


run-time
CLS ( Common Language Specification)

● CLS defines a set of minimum rules for all


compilers that plan to generate managed code for
.NET application
● Ensures source code compiled by a .NET compiler
interoperates with .NET Framework
● A component of .NET Application created in one
prof. Rohan kishor parab

language can be used by other language if both


satisfy the CLS rules.
● Classes from one component created using one
language can be used by other language if both
satisfy the CLS rules
Managed and Unmanaged Code
● Managed Code:
– The code, which is developed in .NET framework, is
known as managed code.
– This code is directly executed by CLR with help of
managed code execution.
– Any language that is written in .NET Framework is
prof. Rohan kishor parab

managed code.

● Unmanaged Code:
– The code, which is developed outside .NET,
Framework is known as unmanaged code.
CTS (Common Type System)

● Variables used in managed code of .NET


application are defined using CTS.
● Enables cross-language integration ,type
safety and high performance code execution.
● All types are derived from a common class
prof. Rohan kishor parab

System.object
● Supports two main categories:
– Value types
– Reference types
● Value types:
– Directly contain the data
– Actual data is always stored on stack
– E.g. Structure
prof. Rohan kishor parab

● Reference types:
– Store a reference to the memory address on the
stack but actual data stored on heap
– E.g. Class
prof. Rohan kishor parab
Take the following method:

● public int AddFive(int pValue)


{
int result;
result = pValue + 5;
return result;
}
prof. Rohan kishor parab
prof. Rohan kishor parab
public class MyInt
{
public int MyValue;
}
public MyInt AddFive(int pValue)
{
MyInt result = new MyInt();
prof. Rohan kishor parab

result.MyValue = pValue + 5;
return result;
}
prof. Rohan kishor parab
FCL (Framework Class Library)

● .NET framework has provided huge class library


for developing windows, web and mobile
applications.
● Namespaces are like packages in Java
● E.g. System is the highest level namespace
prof. Rohan kishor parab

called as Root Namespace


Namespaces Collections

● It is container of objects
● They may contain unions, classes, structures,
interfaces, enumerators and delegates.
● The main goal of using namespace in .net is for
creating a hierarchical organization of program
prof. Rohan kishor parab

● In .NET framework every program is created with


default namespace.
Name Space Usage

System Highest level namespace

System.web Classes to develop web


applications
System.Windows.Form Classes to develop
windows based application
System.Drawing Classes used for drawing
shapes, curves
prof. Rohan kishor parab

System.Data Classes used for data


access in applications
System.Xml Classes used to read, write
XML documents
The using Keyword

● The using keyword states that the program is


using the names in the given namespace.
● For example,we are using the System
namespace in our programs.
● The class Console is defined there. We just write:
prof. Rohan kishor parab

– Console.WriteLine ("Hello there");

● We could have written the fully qualified name as:


– System.Console.WriteLine("Hello there");
● Refer Namespace.txt
– Namespace example
prof. Rohan kishor parab
Execution of .NET Application

● .NET Source code is compiled twice before


execution
1. Source code is compiled into MSIL (Microsoft
Intermediate Language)with the help of language
specific compiler. For example, CSC compiler for
C# and VBC compiler for VB.NET
prof. Rohan kishor parab

2. C# compiler compiles source code into MSIL


code
3. MSIL code is stored in file with extension either
.dll or .exe. It is called as Assembly
4. The MSIL code is then compiled by
Just-In-Time (JIT) compiler into native
executable code
5. This executable code is then processed by
machine’s processor.
prof. Rohan kishor parab

The source code is compiled into executable file


(Assembly), which is represented as a .DLL or
.EXE
Execution of .NET Application
CLR (Common Language Runtime)

● CLR is an execution engine for .NET Applications


● CLR converts the MSIL code into the native
code
● The .NET version is actually CLR version
● Services of CLR
prof. Rohan kishor parab

– Secure Execution of code


– Automatic Memory Management
– Interoperability
– Exception Handling
Comparison to
Java compile execute
Hello.java Hello.class JVM

Source code Byte


code

compile execute
Hello.vb Hello.exe CLR

Source code CIL


● Assembly Loader:
– It first locates the assembly which contains Main() and
then loads it into memory.
– It also locates and loads other classes from FCL

JIT (Just-In-Time) Compiler:


prof. Rohan kishor parab


– There are three types of JIT compilers
1. Standard JIT
2. Pre JIT
3. Econo JIT
JIT (Just-In-Time) Compiler

● The JIT compiler is an important element of


CLR, which loads MSIL on target machines for
execution
● Just-in-time compiler is a compiler used to
convert the Common Intermediate Language
(CIL) code into native code (also called machine
prof. Rohan kishor parab

code) that is processed by machine.


Assembly

● Assembly is logical unit of deployment.


● When you compile an application, the MSIL code
created is stored in an assembly.
● The .NET assemblies could be in the form of an
application(EXE) or class library (DLL).
prof. Rohan kishor parab

● An assembly is a collection of types and


resources that forms a logical unit of functionality.
● CLR provides execution environment for the
assemblies.
Component of an Assembly

● Manifest:
– It contains the assembly information
● Type Metadata:
– Provides information about all the types defined in the
assembly( assembly’s version, security, identity etc )
MSIL code:
prof. Rohan kishor parab


– The compiler convert the source code into Microsoft
Intermediate Language (MSIL)
– Is a CPU-independent set of instructions that can be
efficiently converted to the native code.
Types of Assembly

1. Private Assembly:
– Private assembly is used by a single application.
– Private assembly will be stored in the specific
application's directory or sub-directory.
– Strong name is not required for private assembly.
2. Shared Assembly:
prof. Rohan kishor parab

– Public assembly can be used by multiple application


– Public assembly is stored in GAC
– Strong name has to be created for public assembly.
– Strong names guarantee name uniqueness
Garbage Collector

● Every program needs memory. Unfortunately,


memory is finite.
● Software must cope with memory usage, and
there are two ways to manage it: manually and
automatically.
prof. Rohan kishor parab

● Manual memory management is prone to errors,


especially with exceptions and asynchronous
code.
● Every time your application instantiates a
reference-type object, the CLR allocates space
on the managed heap for that object.
● However, you never need to clear this memory
manually.
prof. Rohan kishor parab

● As soon as your reference to an object goes out


of scope (or your application ends), the object
becomes available for garbage collection.
● The garbage collector runs periodically inside the
CLR, automatically reclaiming unused memory for
inaccessible objects.
● The .NET Framework provides automatic memory
management called garbage collection
prof. Rohan kishor parab

● A .NET program that runs in a managed


environment is provided with this facility by .NET
CLR(common language runtime).
● The purpose of using Garbage Collector is to
clean up memory.
● In .NET all dynamically requested memory is
allocated in the heap which is maintained by CLR.
prof. Rohan kishor parab

● Any objects without reference will be removed at


the time of garbage collection
Error Handling

Prof. Rohan kishor parab


prof. Rohan kishor parab
Types of Error Handling

1. Syntax Errors(Compile-Time Errors):


- Code that has serious errors is never be allowed to
execute
- C# will not make .exe file

2. Logical Errors(Run-Time Errors)


prof. Rohan kishor parab

- Encountered when the program is being executed


- Run time errors are those that passed compiler's
checking, but fails when the code gets executed.
C# - Exception Handling

● Exceptions provide a way to transfer control from


one part of a program to another. C# exception
handling is built upon four keywords:
1. try
2. catch
prof. Rohan kishor parab

3. finally
4. throw
● try: A try block identifies a block of code for which
particular exceptions will be activated. It's
followed by one or more catch blocks.

● catch: A program catches an exception with an


prof. Rohan kishor parab

exception handler at the place in a program


where you want to handle the problem. The catch
keyword indicates the catching of an exception.
● finally: The finally block is used to execute a
given set of statements, whether an exception is
thrown or not thrown.

● throw: A program throws an exception when a


prof. Rohan kishor parab

problem shows up. This is done using a throw


keyword.
prof. Rohan kishor parab
prof. Rohan kishor parab
User-Defined Exceptions

Prof. Rohan kishor parab


prof. Rohan kishor parab
prof. Rohan kishor parab
● When the above code is compiled and executed,
it produces the following result:

TempIsZeroException: Zero Temperature found


prof. Rohan kishor parab
Base Keyword

Prof. Rohan kishor parab


prof. Rohan kishor parab
prof. Rohan kishor parab
prof. Rohan kishor parab
Introduction to ASP.NET 4

Prof. Rohan kishor parab


prof. Rohan kishor parab
ASP.NET Architecture
prof. Rohan kishor parab

● HTTP request takes a trip from the client browser


to the web server and the response is routed
back to the browser
IIS

● IIS is a web server.


● It maintains a mapping between file extensions and
internet service API(ISAPI)
● This dll is capable of mapping request depending on the
extension of the page.
● When extension is aspx the request is routed to
prof. Rohan kishor parab

aspnet_isapi.
● The request is the piped using HttpPipeline to the worker
process
● Web application are hosted on IIS using virtual directory
● Static files handled separately.

● Global.asax only runs with ASP.NET.

● Extensions mapped to ASP.NET include *.aspx


prof. Rohan kishor parab

and *.ashx. And extensions mapped to IIS 7


include *.html, *.gif, static web page file
extensions, and directories.
Creating a Virtual Directory

1. First, right click on


Default web sites >
New > Virtual
Directory.
prof. Rohan kishor parab
2. By selecting "Virtual
Directory...", the virtual
directory creation
wizard will start. Click
on "Next".
prof. Rohan kishor parab
3. Give the "Alias" name
and proceed for "Next".
The alias name is your
virtual directory name.
prof. Rohan kishor parab
4. "virtual directory"
does not contain any
physical file. We need to
define the physical file
path that it will refer to.
We have to browse the
prof. Rohan kishor parab

physical path over here.


5. Now based on your
requirements, you can
select the check boxes
and click on "Next".
Generally, we select only
the "Read" option.
prof. Rohan kishor parab
● For more information
refer
http://www.codeproject
.com/Articles/42724/B
eginner-s-Guide-Explo
ring-IIS-With-ASP-NE
prof. Rohan kishor parab

T
ASP.NET Worker Process

● The Process which is responsible for all asp.net


requests and response cycle is known as worker
process.
● It is responsible for processing Asp.net
application request and sending back response
to the client
prof. Rohan kishor parab

● A regular Web server contains only a single


ASP.NET worker process.
● Each server in the group of servers handles a
separate ASP.NET worker process.
prof. Rohan kishor parab
prof. Rohan kishor parab
HTTP Pipeline

● ASP.NET engine is referred as ASP.NET HTTP


Pipeline
● This forwards the request from IIS to the worker
process
prof. Rohan kishor parab
Request / Response

● When the user hits the enter key after typing the
URL, the browser sends an HTTP GET request to
the target site
● It is received at port 80(default port) by web
server(IIS)
prof. Rohan kishor parab

● The web server is in a listening mode till it


receives a request from the client
● The IIS communicates with ASP.NET through
ISAPI.dll
prof. Rohan kishor parab
prof. Rohan kishor parab
prof. Rohan kishor parab
prof. Rohan kishor parab
prof. Rohan kishor parab
prof. Rohan kishor parab
prof. Rohan kishor parab
prof. Rohan kishor parab
prof. Rohan kishor parab
prof. Rohan kishor parab
prof. Rohan kishor parab

You might also like