Web Serviced API
All web services are
All APIs are not web services.
APIs.
Responses are formatted using Web API’s MediaTypeFormatter into XM
It supports XML.
other given format.
You need a SOAP
protocol to send or
receive and data over
the network. API has a light-weight architecture.
Therefore it does not
have light-weight
architecture.
It can be used by any
client who It can be used by a client who understands JSON or XML.
understands XML.
Web service uses
three styles: REST,
API can be used for any style of communication.
SOAP, and XML-RPC
for communication.
It provides supports
only for the HTTP It provides support for the HTTP/s protocol: URL Request/Response He
protocol.
Advantages of API Services
Here are pros/benefits of using API:
API supports traditional CRUD (Create Read Update Delete) actions as it
works with HTTP verbs GET, PUT, POST, and DELETE.
API helps you to expose service data to the browser
It is based on HTTP, which is easy to define, expose in REST-full way.
Web API is an API as the name suggests, it can be accessed over the web using the HTTP
protocol. It is a framework that helps you to create and develop HTTP based RESTFUL
services.
Soap Vrs Rest
SOAP stands for Simple Object Access Protocol and REST stands
for REpresentational State Transfer.
Since SOAP is a protocol, it follows a strict standard to allow
communication between the client and the server whereas REST is an
architectural style that doesn’t follow any strict standard but follows six
constraints defined by Roy Fielding in 2000. Those constraints are –
Uniform Interface, Client-Server, Stateless, Cacheable, Layered System,
Code on Demand.
SOAP uses only XML for exchanging information in its message format
whereas REST is not restricted to XML and its the choice of
implementer which Media-Type to use like XML, JSON, Plain-text.
Moreover, REST can use SOAP protocol but SOAP cannot use REST.
On behalf of services interfaces to business logic, SOAP uses
@WebService whereas REST instead of using interfaces uses URI like
@Path.
SOAP is difficult to implement and it requires more bandwidth whereas
REST is easy to implement and requires less bandwidth such as
smartphones.
Benefits of SOAP over REST as SOAP has ACID compliance transaction.
Some of the applications require transaction ability which is accepted
by SOAP whereas REST lacks in it.
On the basis of Security, SOAP has SSL( Secure Socket Layer) and WS-
security whereas REST has SSL and HTTPS. In the case of Bank Account
Password, Card Number, etc. SOAP is preferred over REST. The security
issue is all about your application requirement, you have to build
security on your own. It’s about what type of protocol you use.
content negotiation is performed by the runtime (at the server side) to determine
the media type formatter to be used based to return the response for an incoming
request from the client side. Content negotiation is centered on Media type and Media
type formatter.
Difference between Rest and Restful
Attributes REST RESTful
Definitions It is used to develop APIs which It is a web application that follows
enable interaction between the the REST infrastructure, which
client and the server. It should be provides interoperability between
used to get a piece of data when different systems on the entire
the user connects any link to the network.
particular URL.
Web services The working of the URL is based The working of RESTful is
on request and response completely based on REST
applications.
Data format The data format of REST is based The data format of RESTful is based
on HTTP. on JSON, HTTP, and Text.
Adaptability The protocol is strong, and it It is multi-layer and has a transport
inherits many security measures, protocol which makes the system
which are built-in architecture less secure when compared with
layers. REST.
Bandwidth Consumes only minimum Consumes less bandwidth.
bandwidth.
Protocol The protocol is strong, and it It is multi-layer and has a transport
inherits many security measures, protocol which makes the system
which are built-in architecture less secure when compared with
layers. REST.
What is .Net framework?
.NET framework is developed by Microsoft which provides an environment to run, debug and deploy
code onto web services and applications by using tools and functionalities like libraries, classes, and
APIs. It supports different languages like C#, Cobol, VB, Perl, etc.
Main components of .NET framework
Common Language Runtime- It is an execution engine that runs the code and provides services that
make the development process easier.
Framework Class Library- It has pre-defined methods and properties to implement common and
complex functions that can be used by .NET applications.
How does the .NET framework work?
.NET framework-based applications that are written in supportive languages like C#, F#, or Visual
basic are compiled to Common Intermediate Language (CIL).
Compiled code is stored in the form of an assembly file that has a .dll or .exe file extension.
When the .NET application runs, Common Language Runtime (CLR) takes the assembly file and
converts the CIL into machine code with the help of the Just In Time (JIT) compiler.
Now, this machine code can execute on the specific architecture of the computer it is running on.
What is CTS?
CTS stands for Common Type System. It follows a set of structured rules according to which a data
type should be declared and used in the program code. It is used to describe all the data types that
are going to be used in the application.
We can create our own classes and functions by following the rules in the CTS. It helps in calling the
data type declared in one programming language by other programming languages.
Explain CLS
Common Language Specification (CLS) helps the application developers to use the components that
are inter-language compatible with certain rules that come with CLS. It also helps in reusing the code
among all of the .NET-compatible languages.
What is JIT?
Just-In-Time compiler (JIT) is a part of Common Language Runtime (CLR) in .NET which is responsible
for managing the execution of .NET programs regardless of any .NET programming language.
A language-specific compiler converts the source code to the intermediate language. This
intermediate language is then converted into the machine code by the Just-In-Time (JIT) compiler.
This machine code is specific to the computer environment that the JIT compiler runs on.
What is an assembly?
An assembly is a file that is automatically generated by the compiler which consists of a collection of
types and resources that are built to work together and form a logical unit of functionality. We can
also say, assembly is a compiled code and logical unit of code.
Assemblies are implemented in the form of executable (.exe) or dynamic link library (.dll) files.
Explain the different types of assembly.
Private Assembly:
It is accessible only to the application.
We need to copy this private assembly, separately in all application folders where we want to use
that assembly. Without copying, we cannot access the private assembly.
It requires to be installed in the installation directory of the application.
Shared or Public Assembly:
It can be shared by multiple applications.
Public assembly does not require copying separately into all application folders. Only one copy of
public assembly is required at the system level, we can use the same copy by multiple applications.
It is installed in the Global Assembly Cache(GAC).
What is a garbage collector?
Garbage collector frees the unused code objects in the memory. The memory heap is partitioned
into 3 generations:
Generation 0: It holds short-lived objects.
Generation 1: It stores medium-lived objects.
Generation 2: This is for long-lived objects.
Collection of garbage refers to checking for objects in the generations of the managed heap that are
no longer being used by the application. It also performs the necessary operations to reclaim their
memory. The garbage collector must perform a collection in order to free some memory space.
During the garbage collection process:
The list of live objects is recognized.
References are updated for the compacted objects.
The memory space occupied by dead objects is recollected. The remaining objects are
moved to an older segment.
System.GC.Collect() method is used to perform garbage collection in .NET.
What is caching?
Caching means storing the data temporarily in the memory so that the data can be easily accessed
from the memory by an application instead of searching for it in the original location. It increases the
speed and performance efficiency of an application.
There are three types of caching:
1. Page caching
2. Data caching
3. Fragment caching
Difference between an abstract class and an
interface?
Abstract Class Interface
Used to declare properties, events, Fields cannot be declared using
methods, and fields as well. interfaces.
Provides the partial implementation Used to declare the behaviour of an
of functionalities that must be implementing class.
implemented by inheriting classes.
Different kinds of access modifiers Only public access modifier is
like private, public, protected, etc. supported.
are supported
It can contain static members It does not contain static members.
Multiple inheritances cannot be Multiple inheritances are achieved.
achieved.
Types of memories supported in the .NET
framework?
Two types of memories are present in .NET. They are:
Stack: Stack is a stored-value type that keeps track of each executing thread and its location. It is
used for static memory allocation.
Heap: Heap is a stored reference type that keeps track of the more precise objects or data. It is used
for dynamic memory allocation.
What's Connection Pooling?
Connection pooling is the ability to re-use your connection to the Database. This means if you enable
Connection pooling in the connection object, actually you enable the re-use of the connection to
more than one user.
Different parts of an Assembly.
The different parts of an assembly are:
Manifest – It holds the information about the version of an assembly. It is also known as assembly
metadata.
Type Metadata – It consists of binary information of the program.
MSIL – Microsoft Intermediate Language code.
Resources – List of related files.
Types of cookies available in ASP.NET?
Two types of cookies are available in ASP.NET. They are:
Session Cookie: It resides on the client machine for a single session and is valid until the user logs
out.
Persistent Cookie: It resides on the user machine for a period specified for its expiry. It may be an
hour, a day, a month, or never.
Remote Validation
While performing model validation, at times you need to validate values entered in client side
controls against server side data. Such a validation is called remote validation. As you might have
guessed remote validation uses Ajax to validate the data. Thus validation is initiated on the client
side but performed on the server side. The outcome of the validation process is sent back to the
client so that the end user can be notified accordingly.