Академический Документы
Профессиональный Документы
Культура Документы
What is Polymorphism?
Polymorphism means the ability to take more than one form.
Polymorphism Plays an Important role in allowing Objects having different internal Structures
to share the same external interface.
The benefit of Polymorphism is when the appropriate implementation is invoked automatically
at runtime depending on the type of Object.
pWhat are different types of Polymorphisms that are available
?
Operation Polymorphism or Compile
Polymorphism(EarlyBinding/StaticBinding/StaticLinking)-Using OverLoaded Methods-The
Compiler is able to select and bind the appropriate method to the object for a Particular call at
Compiletime Itself.
Eg. Class Dog{}
Class Cat{}
Class Operation{
static void Call(Dog d){}
static void Call(Cat c){} }
Public static void Main(){
Dog d=new Dog();
Cat c=new Cat();
Call(d);
Call(c);
}
What is Class?
Class is a template of class.
What is Object?
Object is an instance of a class.
What is Interface?
Like class Interface contains, properties, methods, but interfaces doesn’t contain
implementation of those methods.
Interface defines only Abstract Methods and Final fields.
An Interface represents a contract and a class that implements an Interface must implement
every aspect of that interface exactly as it is defined.
An Interface is implemented and not extended.
1.A class can implement multiple interfaces.
2.An Interface can’t contain data declarations but you can declare properties.
3.All method declarations in an Interface are Public.
4.There can be no implementation in an Interface.
5.A class implementing the interface must provide implementation code.
6.An Interface can be derived from another Interface.
What is an Abstract Class?
An Abstract class is a class that contains methods that have no implementation(i.e abstract
methods).
An abstract method is simply a shell or place-marker for a method that will be defined later in a
derived class.
The intention of abstract methods is to force every derivation of the class to implement those
methods. If a derived class does not implement an abstract method , then that class must also be
declared as abstract.
An Abstract class is the class that can’t be instantiated(i.e no direct instances), but must be
inherited from. (but whose descendents may have direct instances)
An Abstract class is usually partially implemented or not implemented at all, there by
encapsulating common functionality for inherited classes.
NB:-Derived class is also called Concrete class. And Implementation of Abstract class is
optional, unlike interface.
MustInherit-Class/MustOverridable-Method-vb.net
Abstract(Class&Method) –C#
Differences between an Abstract Class and Interface?
What is Enum?
Enums specify a group of named numeric Constants.
An Enum can be of Type byte, short, int or long.
Public enum Direction: byte{Northe=1,Easr=2,West=4,South=8}
What is Structure?
Structures can be think as Light weight, memory efficient Classes.
Structure is a User defined Structure, similar to Class. It’s a Class of Value Type. It can have
one or more Attributes, of any of other Datatypes.It can also have methods. A Struct object is
created using new Keyword, just like a Class.
What is the difference between a Struct and a Class?
The struct type is suitable for representing lightweight objects such as Point,
Rectangle, and Color. Although it is possible to represent a point as a class, a
struct is more efficient in some scenarios. For example, if you declare an array of
1000 Point objects, you will allocate additional memory for referencing each
object. In this case, the struct is less expensive.
When you create a struct object using the new operator, it gets created and the
appropriate constructor is called. Unlike classes, structs can be instantiated
without using the new operator. If you do not use new, the fields will remain
unassigned and the object cannot be used until all of the fields are initialized.
It is an error to declare a default (parameterless) constructor for a struct. A
default constructor is always provided to initialize the struct members to their
default values.
It is an error to initialize an instance field in a struct.
There is no inheritance for structs as there is for classes. A struct cannot inherit
from another struct or class, and it cannot be the base of a class. Structs, however,
inherit from the base class Object. A struct can implement interfaces, and it does
that exactly as classes do.
A struct is a value type, while a class is a reference type.
What is Shadowing?
Shadowed members are used to create the Local version of members that have broader scope.
Shadowing is used when two programmers come up with same method in the same class , one of
the methods get shadowed by scope or inheritance.
What is Virtual method?
The Concept of Virtual method is such that the bottom-most implementation of the method is
always used in favor of the Parent implementation-regardless of the data type of variable being
used in the client code.
Virtual method has an implementation and Provide the derived class with the option of
overriding it. The class which contains Virtual methods is known as Virtual Class.
Override modifier is used while overriding an Virtual method.
1.Public:-Entries that are declared as Public, have public access. There is no Restriction on the
accessibility of Public Entries.
2.Protected:- Entries that are declared as Protected, have protected access. They are accessible
only from their own classes or from a Derived class.
3.Friend(Internal):- Entries that are declared as Friend, have friend access. They can be
accessible from within the program that contains the Declaration and within the Assembly.
4.Private:- Entries that are declared as private, have private access. They can be accessible
only within the Class.
5.Protected Friend/Protected Internal:- Entries that are declared as Protected Friend, have
Protected Friend. They can be accessible from within the program that contains the
Declaration and within the Assembly and in the Derived Classes also.
What is Overriding?
Overriding is Defining a method in Derived class that has the same name ,same arguments and
same return type as a method in Base Class.
Overridable/Overrides/NotOverridable(sealed)/MustOverride(abstract)---vb
Virtual/Override---C#
i.e Class,Arrays,Interfaces,Delegate.
Data Type is an attribute that specifies the type of data that object can hold.
System.Boolean ( 1 byte
System.Byte ( 1 byte
System.Char ( 2 bytes
System.Int16 ( 2 bytes
System.Int32 ( 4 bytes
System.Int64 ( 8bytes
System.Object ( 4bytes
System.Single ( 4bytes
System.Double ( 8bytes
System.Decimal ( 12bytes
System.DateTime ( 8bytes
System.String ( 10bytes +(2*string length)
System.ValueType ( Sum of Member sizes(User Defined Type)
Value type & reference types difference? Example from .NET. Integer & struct are
value types or reference types in .NET?
Most programming languages provide built-in data types, such as integers and floating-point
numbers, that are copied when they are passed as arguments (that is, they are passed by value).
In the .NET Framework, these are called value types. The runtime supports two kinds of value
types:
Built-in value types
The .NET Framework defines built-in value types, such as System.Int32 and
System.Boolean, which correspond and are identical to primitive data types used
by programming languages.
User-defined value types
Your language will provide ways to define your own value types, which derive
from System.ValueType. If you want to define a type representing a value that is
small, such as a complex number (using two floating-point numbers), you might
choose to define it as a value type because you can pass the value type efficiently
by value. If the type you are defining would be more efficiently passed by
reference, you should define it as a class instead.
Variables of reference types, referred to as objects, store references to the actual data.
This following are the reference types:
class
interface
delegate
This following are the built-in reference types:
object
string
What is Boxing and Unboxing?
Boxing is a mechanism of converting a value type to reference type.
Un Boxing is a mechanism of Converting reference type to value type.
What are Different Object types offered by CLR?
There are two types of Object types that are offered by CLR. They are
a) Value Types
b) Reference Types
Reference Types are always allocated from the managed heap and the new operator returns the
memory address of object and Garbage collector take care of freeing of memory resources.
Eg: Strings,objects etc
Value Types are allocated on a thread’s stack and variable representing the object does not
contain a pointer to an object. Value types are lightweight than reference types because they
are not allocated in managed heap, not garbage collected and not referenced to by pointers.
Value type is referred as structure. value type is primitive type and type does not inherit from
another type.
Eg: int32,Boolean,decimal etc.
NB:-Heap is Temporary Memory i.e RAM and Stack is Permanent Memory i.e HardDisk.
What are Custom Attributes?
Custom Attributes are used to adorn type,methods,fields etc.
When compiled the compiler emits these method attributes into the managed module’s
metadata. At runtime, this metadata can be examined and based on the presence of these
attributes the behaviour of the application changes.
To use Early binding you need to set a reference in your project to the application you want
to manipulate.
Eg. Dim oXL as Object
Set oXL=New Excel.Application
What are the advantages of early binding and late binding?
Advantages of Early Binding: -
1.Code will run considerably faster, because it can all be compiled up front, but in late
binding the code is compiled as it runs.
2.As code is compiled up front, debugging is far easier and compiler will able to spot
syntax errors which would have been missed had you used late binding.
3.We can have full access to Intellisense in the project.
4.We can access the application’s built-in constants.
Eg. .windowState=wdWindowStateMaximize
In LateBinding, we use it like the following
.windowState=1
An interface
A third party class must be
Third party implementation may be
rewritten to extend only from the
convenience added to any existing
abstract class.
third party class.
Plug-in You can write a new You must use the abstract class
replacement module for as-is for the code base, with all
an interface that contains its attendant baggage, good or
not one stick of code in bad. The abstract class author
common with the has imposed structure on you.
existing implementations. Depending on the cleverness of
When you implement the the author of the abstract class,
interface, you start from this may be good or bad.
scratch without any Another issue that's important is
default implementation. what I call "heterogeneous vs.
You have to obtain your homogeneous." If
tools from other classes; implementors/subclasses are
nothing comes with the homogeneous, tend towards an
interface other than a few abstract base class. If they are
constants. This gives you heterogeneous, use an interface.
freedom to implement a (Now all I have to do is come up
radically different with a good definition of
internal design. hetero/homogeneous in this
context.) If the various objects
are all of-a-kind, and share a
common state and behavior, then
tend towards a common base
class. If all they share is a set of
method signatures, then tend
towards an interface.
No additional parameters are permitted after the params keyword in a method declaration, and only one params
keyword is permitted in a method declaration.
2 .NET FRAMEWORK:-
It Provides Cross-Language Inheritance and abilty to compile once and run on any CPU and OS
that supports runtime through Compilers.
Memory management. The CLR maintains a managed heap that is used for all memory
allocations. The CLR also cleans up objects that are no longer used. Because of the
information found in IL and Metadata, the CLR is able to enforce that references always
refer to compatible types, null references are never accessed, instances are never
referenced after they are freed, etc. This is one very important aspect of code management
performed by the Common Language Runtime.
Security. The CLR makes sure that code can not undermine a system if it is not trusted.
An example of un-trusted code would be a binary that was downloaded and executed from
a website. The great thing about managed code is that the un-trusted software still runs at
full native speed. However, at the point of JIT-compiling, the CLR was able to insert
enough code to assure that security cannot be breached. If the executable crosses the line,
the CLR knows about it, and will raise a security exception. This will cause the
unacceptable operation to fail.
Thread management. Although you can create your own thread objects with managed
code, the CLR maintains a thread pool which can be used by your software. The thread
pool efficiently uses threads for asynchronous behavior, and then returns an unused thread
to a queue until it is needed again.
Type safety. It is impossible for managed code to coerce a type into an incompatible type.
At runtime the CLR checks all typecasting operations to be sure that the cast is valid.
Because managed code uses references to objects in a managed heap (rather than
pointers), it is also impossible to coerce one type to another through pointer manipulation.
This drastically reduces bugs, and removes the fear that third-party code might undermine
the integrity of your system.
Code verification. The CLR asserts certain truisms about managed code. For example,
the CLR (by default) will not JIT compile code that references a variable before it has
been assigned to. The CLR can also be made to JIT compile code so that numerical
operations that overflow raise exceptions so that they can be caught (although this is not
the default). The CLR also asserts that all methods must have a return instruction. It is
impossible for one instruction to run-over into the next. Code verification is another
feature that makes code robust, and makes it safe to run un-trusted or semi-trusted
components.
Data Type is an attribute that specifies the type of data that object can hold.
System.Boolean 1 byte
System.Byte 1 byte
System.Char 2 bytes
System.Int16 2 bytes
System.Int32 ( 4 bytes
System.Int64 ( 8bytes
System.Object ( 4bytes
System.Single ( 4bytes
System.Double ( 8bytes
System.Decimal ( 12bytes
System.DateTime ( 8bytes
System.String ( 10bytes +(2*string length)
System.ValueType ( Sum of Member sizes(User Defined Type)
What is Manifest?
Manifest is the set of Metadata that describes the contents of the assembly and the Metadata also
describes the dependencies and Version Information associated with an assembly.
What are different types of Assemblies?
There are Two Types of Assemblies. They are Private Assembly and Shared Assembly.
Private Assembly is used by a single application and is stored in Application Directory or a
subdirectory beneath.
Shared Assembly is used by Multiple Applications and is Stored in Global Assembly
Cache(GAC).Runtime enforces Versioning Constraints on Shared Assemblies only and not on
Private Assemblies.
What is GAC?
Global Assembly Cache is a repository of assemblies maintained by .NET runtime.
How Assebly Dll or exe is checked?
Using ILDASM.EXE Utility.
What is reflection?
All .NET compilers produce metadata about the types defined in the modules they
produce. This metadata is packaged along with the module (modules in turn are packaged
together in assemblies), and can be accessed by a mechanism called reflection. The
System. Reflection namespace contains classes that can be used to interrogate the types
for a module/assembly.
Using reflection to access .NET metadata is very similar to using ITypeLib/ITypeInfo to
access type library data in COM, and it is used for similar purposes - e.g. determining data
type sizes for marshaling data across context/process/machine boundaries.
Reflection can also be used to dynamically invoke methods (see
System.Type.InvokeMember), or even create types dynamically at run-time (see
System.Reflection.Emit.TypeBuilder).
.NET Class Library is a collection of reusable types that are tightly integrate with the Common
Language Runtime, from which your own Managed Code can derive functionality.
What is Application Domain?
Application Domain is a Construct in the CLR that is the unit of isolation for an application.
The Isolation Guarantees the following:
a) An Application Can be Independently stopped.
b) An Application cannot directly access code or resources in another application.
c) A fault in an application cannot affect other applications.
What platforms do the .NET Framework run on?
The runtime supports Windows XP, Windows 2000, NT4 SP6a and Windows ME/98.
Windows 95 is not supported. Some parts of the framework do not work on all platforms -
for example, ASP.NET is only supported on Windows XP and Windows 2000. Windows
98/ME cannot be used for development.
Garbage collection is an algorithm. It works by periodically running through a list of all the
objects that are currently being referenced by an application. All objects that it doesn’t find
during this search are ready to be destroyed and the memory reclaimed.
The Implication of this algorithm is that the runtime doesn’t get notified immediately when the
final reference on an object goes away-it only finds out during the next sweep of the heap.
For this Microsoft Recommends Dispose() method and Finalize() methods, to get freed object
resources.
NB:- System.GC class provides Collect method that uses to collect all un referenced objects
immediately.
The syntax implementing the Dispose method of the IDisposable interface and overriding the
Finalize method of the Object class is shown with this table:
IL C++/CLI C# VB
Dispose ~ClassName Dispose Dispose
Finalize !ClassName ~ClassName Finalize
Visual Basic does not hide Dispose and Finalize. The automatically created code
(with Visual Studio 2005) also includes the Dispose(bool) pattern.
class Resource : IDisposable
{
private bool disposed = false;
~Resource()
{
Dispose(false);
}
disposed = true;
}
2.PAGE:-
In general, the life cycle for a Web Forms page is similar to that of any Web process that runs on
the server. Certain characteristics of Web processing — information passed via HTTP protocol,
the stateless nature of Web pages, and so on — apply to Web Forms pages just as they do to
most Web applications.
The ASP.NET page framework performs many Web application services for you. For example,
the ASP.NET page framework captures information posted with the Web Forms page, extracts
the relevant values, and makes the information accessible via object properties.
What is RoundTrip?
For Each user action on the form, the form must be posted to the server, processed, and returned
to the browser. This sequence of events is referred to as a round trip.
In Web Forms, most user actions — such as clicking a button — result in a round trip.
In any Web scenario, pages are recreated with every round trip.
For that reason, the events available in ASP.NET server controls are usually limited to click-type
events.
By the same token, server controls do not expose high-frequency events such as onmouseover,
because each time such an event is raised, another round trip to the server would occur, which
would considerably affect response time in the form.
Why pages are said to be stateless?
The values of a page's variables and controls are not preserved on the server.
In a traditional Web application, the only information that the server has about a form is the
information that the user has added to the controls on the form, because that information is sent
to the server when the form is posted. Other information, such as variable values and property
settings, is discarded.
ASP.NET works around these limitations in the following ways:
It saves page and control properties between round trips. This is referred to as saving the
view state of the control.
It provides state management facilities so you can save your own variable and
application-specific or session-specific information between round trips.
It can detect when a form is requested for the first time versus when the form is posted,
which allows you to program accordingly. You may want a different behavior during a
page postback versus an initial request.
3.ASP.NET:-
3. The xspisapi.dll isapi filter intercepts the request and passes the request on to the XSP
worker process (xspwp.exe)
4. Xspwp takes care of handing the request to the appropriate HTTPModules and finally
an HTTPHandler as defined in the configuration files.
5. The ASPX page is read from the HardDisk or cache and server code is loaded into
memory and executed.
6. The server side code outputs normal HTML which is handed back through the chain of
modules and eventually to IIS, which sends the response back to the client's browser.
7. If the user clicks or otherwise acts on an HTML element (say, a textbox) that has a
server side event handler, the form is posted back to the server with hidden form fields
containing information as to what control and event occurred. Some controls do not
automatically post by default, but wait for a button_click event to post. This is
configurable by the developer.
8. The ASPx page is again loaded into memory using the same sequence of events as
before, but this time ASP.net reads in the hidden form field data and automagically
triggers the appropriate _OnChange, OnClick and other appropriate event handlers.
HTTP Handlers provide the end point in the processing of a web request and are equivalent to
ISAPI Extensions today. For example, many handlers can be involved in the request for an
ASPX page, but only 1 handler is invoked. The handler runs after the HTTP modules have
run. Which handler is invoked is determined by configuration settings in the config.web
file. Handlers are assigned to handle requests based on the extension of the page requested.
1.Limit no. of Components Instantiated at Application/Session Level, since these Objects will
be Consuming Resources(Such as memory) for entire life time of Application/Session, which
causes Scalability Problems.
NB:-Record set was not XML-based and could not be serialized to XML easily or flexibly.
4.CONTROLS:-
ASP.NET Provides a set of Web Server Controls called validation controls that provide
sophisticated validation on both the client side and the server side depending on the validation
settings and the browser’s capabilities.
ASP.NET ensures that all validations are performed on the server side even if they were already
performed on the client-side. This ensures that validations are not by passed if a malicious user
circumvents client-side validation. If the client-side validation fails, the server side validation is
never performed.
When a control is declared to run on the server, a ViewState is created which remembers the ID
of that control, and the method to call when an action is performed. Submit event calls the
JavaScript function __doPostBack. You do not write this function, instead its generated by the
ASP.NET engine and automatically included in our page. It submits the form to the same
page, and accepts 2 arguments.
EventTarget: The control doing the submission.
EventArgumet: any additional information for the event.
If the control is set visible=false, then the java script function will not be included and will not
be able to perform any actions.
ASP.NET also provides some advanced controls like datagrid, datalist , repeater and
calender which provide rich functionality and saves programmer from lot of code.
ASP.NET uses compiled languages rather that scripting languages. For example VB C#,
JScript and Perl.
You can use only one language per page
If you want mix two languages you have to use pagelets.Pagelets are miniature ASP.NET
pages that can be embedded in other pages.
Functions must be inside a <SCRIPT> block rather than <% and %> block
What are HttpHandlers and Httpmodules?
The Main Difference between the two controls lies in ease of creation Vs ease of use at design
time.
Web User Controls are easy to make, its developed exactly same as developing web form pages.
As they are compiled dynamically at runtime they cannot be added to toolbox and They are
represented by simple placeholder glyph when added to the page.
Web custom controls are compiled code , which makes them easier to use but more difficult to
create. Custom controls must be authored in code. Once you have created the control, you can
add it to the toolbox and display it in a visual designer with full properties window support and
all other design-time features of ASP.NET Server controls. In addition, you can install a single
copy of web custom control in the Global Assembly Cache and share it between applications,
which make maintenance easier.
5.DATABASE TECHNOLOGY:-
What is ADO.NET?
ADO.NET is next generation of Data Access Technology from Microsoft Target at .NET
Platform.
ADO.NET is built with Distributed and Internet applications in mind.ADO.NET Provides strong
support for XML and disconnected Data Processing.
What is .NET Data Provider? or What is .NET Managed Provider?
A .NET Data Provider is a set of classes that allow managed code to interact with a specific data
source to retrieve, Update and Manipulate data.
A data provider in the .NET Framework serves as a bridge between an application and a data
source.
What are different types of .NET Data Providers?
ADO.NET currently provides two .NET Data Providers.
a) SQLSERVER .NET Data Provider:-Which provides Optimized access to SqlServer
Databases. For Microsoft® SQL Server™ version 7.0 or later.
b) OLEDB .NET Data Provider:-Which lets you connect to any data source for which you
have an OLEDB Provider is installed. For data sources exposed using OLE DB.
DataAcess API s for both the providers are found in separate namespaces.
What are Data Access Namespaces?
System.Data
System.Data.Oledb
System.Data.SqlClient
System.Data.SqlTypes
System.Data.XML
What are The main Objects in ADO.NET?
1.Connection Object-SqlConnection/Oledb Connection
2.Command Object-SqlCommand/OledbCommand
3.DataReader Object-SqlDataReader/OledbDatareader
4.DataAdapter Object-SqlDataAdapter/OledbDataAdapter
These Are Core Elements of .NET Data Provider Model.
5.Parameter Object-SqlParameter/Oledb Parameter
6.Dataset Object
7.Data Table Object
8.DataView Object
9.Data Row Object
10.Data Column Object
What are connection,Command, DataReader, and DataAdapter Objects?
The Connection, Command, DataReader, and DataAdapter objects represent the core
elements of the .NET data provider model. The following table describes these objects.
Object Description
Connection Establishes a connection to a specific data source. It’s used for
setting or retrieving Properties of a connection or handling
connection Related events.
Command It’s used to Executes sql statements and stored procedures against a
data source. Exposes Parameters and can execute within the scope
of a Transaction from a Connection.
DataReader It Provide Light Weight, High Performance access to forward-only,
read-only stream of data from a data source. It is the best choice for
accessing data to be displayed in ASP.NET. It only contains one row
of data in memory at a time. As in ADO, Once connection to data
source is closed ,the data is not available.
DataAdapter Its used to Populates a Data Set from a given Sql Statement or
Stored Procedure represented by a Sql Command Instance and
update,manipulate and Insert rows in the data source.
Along with the core classes listed in the preceding table, a .NET data provider also contains the
classes listed in the following table.
Object Description
Transaction Enables you to enlist commands in transactions at the data source.
CommandBuilder A helper object that will automatically generate command
properties of a DataAdapter or will derive parameter information
from a stored procedure and populate the Parameters collection
of a Command object.
Parameter Defines input, output, and return value parameters for commands
and stored procedures.
Exception Returned when an error is encountered at the data source. For an
error encountered at the client, .NET data providers throw a .NET
Framework exception.
Error Exposes the information from a warning or error returned by a
data source.
Client Permission Provided for .NET data provider code access security attributes.
Parameters Properties such as Parameter Name, Type (SqlType or OledbType) and Value need to
set and then add the Parameter Object to Parameters collection of the Command Object.
-or-
Address
-or-
Addr
-or-
Network Address
Enlist 'true' When true, the pooler
automatically enlists the
connection in the creation
thread's current transaction
context.
Initial Catalog The name of the database.
-or-
Database
Integrated Security 'false' Whether the connection is to
-or- be a secure connection or
not.
Trusted_Connection Recognized values are 'true',
'false', and 'sspi', which is
equivalent to 'true'.
Max Pool Size 100 The maximum number of
connections allowed in the
pool.
Min Pool Size 0 The minimum number of
connections allowed in the
pool.
Network Library 'dbmssocn' The network library used to
-or- establish a connection to an
instance of SQL Server.
Net Supported values include
dbnmpntw (Named Pipes),
dbmsrpcn (Multiprotocol),
dbmsadsn (Apple Talk),
dbmsgnet (VIA), dbmsipcn
(Shared Memory) and
dbmsspxn (IPX/SPX), and
dbmssocn (TCP/IP).
The corresponding network
DLL must be installed on the
system to which you
connect. If you do not
specify a network and you
use a local server (for
example, "." or "(local)"),
shared memory is used.
Packet Size 8192 Size in bytes of the network
packets used to
communicate with an
instance of SQL Server.
Password The password for the SQL
-or- Server account logging on.
Pwd
Persist Security Info 'false' When set to 'false', security-
sensitive information, such
as the password, is not
returned as part of the
connection if the connection
is open or has ever been in
an open State. Resetting the
connection string resets all
connection string values
including the password.
Pooling 'true' When true, the SQL
Connection object is drawn
from the appropriate pool, or
if necessary, is created and
added to the appropriate
pool.
User ID The SQL Server login
account.
Workstation ID the local computer name The name of the workstation
connecting to SQL Server.
When setting Boolean properties, you can use 'yes' instead of 'true', and 'no' instead of 'false'.
What is Dataset?
Dataset is an In-memory representation of one or more tables of data. Its not specific to
datasource.This data may be read from an XML file or stream or may be result of a query. Rows,
Columns and Constraints objects are properties of DataTableClass. You can put relations and
Constraints within varies data tables of a dataset.
What is Data View?
Data view Class provides a means for sorting, Searching, Editing, Filtering and Navigating
Databases.
Data views can also be DataBound.
What is Data Binding?
Data binding is the process of (Declaratively or Programmatically) tying the elements of UI of a
page (Such as Controls) to data in an underlying Data store.
What are Different types of Data Bound Controls?
Data bound Controls are of three types.
1.Data Grids: This controls Presents Data in a tabular Format.
2.DataLists:This control display Items in Multiple Columns and Can display rows horizontally
and vertically.
3.Repeaters:This controls allows you to work with templates.
6.CACHING&SESSION MANAGEMENT:-
What is State?
The data or a variable that need to be maintained across a series of requests or shared between
multiple users is referred as State.
What is Scalability?
It is the ability of an application to service requests from increasing no. of users without any
significant decrease in performance or response time.
What factors effect Scalability?
1.Failure to disable session state when not used.
2.Misuse of Application.Lock()
3.Storing references to a single threaded Objects.
4.Overuse of Session or Application storage.
What are the ways that ASP.NET supports various Client-side and server-side options
for state management?
Client-Side potions:-
1. ViewState Property
2. Hidden fields
3. cookies
4.QueryString
Server-Side Options:-
1. Application State
2. Session State
3.Data Base
NB:-Session State Storage in ASP.NET is supplied by the .NET HttpSession State Class. An
Instance of which is exposed as the Application Property of the Page Class.
What are the Properties and Methods of an Session Object?
Properties:-
Keys Property : Returns Collection of All keys by which session Collection Values can be
accessed.
Count Property :Returns the number of Objects Stored in the Session Collection.
SessionId Property: Returns a string contain session Id for the current session.
Timeout Property:-Returns a Int32 value reprenting the current sessionTimeOut .
Methods:-
Abandon Method:-Destroys current User session.
Clear Method:-Removes all items from a session Collection.
RemoveAt Method:-Specified items will be removed.
ToString Method:-Returns a string that represents an item in the Session collection .Useful
when a string value is required rather than an Object Reference.
<@page Enablesessionstate=”False”%>
NB:-While designing an application the developer need to consider following things.
1.Maintainability
2.Reusability
3.Portability
4.Security
5.Integrity
6. User Friendliness of Software Products.
What setting are stored in SessionState?
1.User Specific settings:-Most frequently queried data is preserved in Session state. Otherwise
its preserved in a database.
2.Datasets containing frequently queried data is not stored in session state, but is stored in
Asp.net Cache engine.
What are the different types/Ways of storing SessionState?
ASP.NET provides several new possibilities to store session state .They are
1.In process(InProc):This is Default setting. Simple to deal ,but lacks Scalability and
Durability, as state can’t sustain Web application or Webserver shutdowns or Crashes.
2.Out-of-Process(State Server) :This is the First Solution to the problems of Scalability and
Durability for session state by storing session state out of process in a Dedicated ASP.NET State
Process Provided by an NT Service.
Advantages:-
1.Can service requests from multiple servers, making possible to scale session state across a web
form.
2.As ASP.NET State service runs in a separate process so state information can survive restarts
or crashes of a specific web application process.
But can’t survive if a restart or crash occurs on the machine, in which the ASP.NET state service
is running.
To do this change the session state configuration setting
<SessionState
mode =”StateServer”
StateConnectionString=”tcpip=127.0.0.1:42424”/>
Port that monitor ASP.NET StateService.
Now start in services, ASP.NET Stateservice in MicrosoftManagementConsole(MMC)Snap-in.
Disadvantages:-
Retrieving state information from a different machine (i.e Different Process) is significantly
more costly than retrieving it from within the same process.
3.Sqlserver (SQLServer):
The second Solution to the problems of Scalability and durability for session state is
To be store it out of process in a SqlServer Database.
Advantages:-
1.Specified Sql Server can survive requests from multiple servers making it possible to scale
session state across webform.
2.As session state Information is stored in a Sqlserver Database, so state Information can be
survive restarts or crashes of any web application process, even Sqlserver itself.
To enable Sqlserver to store session state 1.run installsqlstate.sql batch.
2. modify session state configuration section in Web.Config.
<SessionState
mode=”Sqlserver”
Sqlconnectionstring=”data source=127.0.0.1;user id=sa;password=sa”>
4.Cookiless Sessions:-
In configuration section set
<Session state
cookiless=”true”/>
In this situation ASP.NET automatically embed the session Id value in the URL for all requests
.If a request doesn’t contain an embedded session Id ,asp.net will create
New session Id and Embed it in the URL for that request.
To prevent this problem, you can manually format URLs by calling ApplyAppPathModifier
method of response intrinsic object and passing it a virtual path.It returns an Absolute URL,
that includes protocol domain,Path and file name necessary to request a given resource.
Mycookie.Expires=Now.address(2)
How Cookies are declared?
VaryByControl:- Sets the names of properties of a user control by which to vary the
caching of the user control output.
This attribute is used with usercontrols only
NB:-Whereas VaryByParam attribute varies cached results based on names/Value pairs sent
using POST or GET , the VaryByControl attribute varies the cached fragment by controls
within the user control.
<%@OutPutCache Duration=”120” VaryByParam=“none” VaryByControl=”Category”%>
NB:- Similar to Output cache pages, explicit use of VaryByParam is required even if it is not
used.
VaryByCustom:-Allows varying of Cached content by browser user agent,browsercapabilities
or custom logic.when set to any value other than Browser, requires that the
HttpApplication.GetVaryByCustomString be overridden in Global.asax in order to Implement
the custom logic.
VaryByHeader:-Allows varying of cached content nased on value of one or more HTTP request
headers.Multiple Properties are separated by semicolons.
This attribute is used only with WebformPages.
Sometimes it is not practical to cache an entire page - perhaps portions of the page must be
created or customized for each request. In this case, it is often worthwhile to identify
objects or data that are expensive to construct and are eligible for caching. Once these items
are identified, they can be created once and then cached for some period of time.
Additionally, fragment caching can be used to cache regions of a page's output.
When Data Caching is used?
ASP.NET provides a full-featured cache engine that can be used by pages to store and
retrieve arbitrary objects across HTTP requests. The ASP.NET cache is private to each
application and stores objects in memory. The lifetime of the cache is equivalent to the
lifetime of the application; that is, when the application is restarted, the cache is recreated.
Key-Value Pairs
NB:- Cache("mykey") = myValue
myValue = Cache("mykey")
For applications that need more sophisticated functionality, the ASP.NET cache supports
scavenging, expiration, and file and key dependencies.
Scavenging means that the cache attempts to remove infrequently used or unimportant items if
memory becomes scarce. Programmers who want to control how scavenging occurs can provide
hints to the scavenger when items are inserted into the cache that indicate the relative cost of
creating the item and the relative rate at which the item must be accessed to remain useful.
Expiration allows programmers to give cache items lifetimes, which can be explicit (for
example, expire at 6:00) or can be relative to an item's last use (for example, expire 20
minutes after the item was last accessed). After an item has expired, it is removed from the
cache and future attempts to retrieve it return the null value unless the item is reinserted into
the cache.
File and key dependencies allow the validity of a cache item to be based on an external file or
on another cache item. If a dependency changes, the cache item is invalidated and removed
from the cache. For an example of how you might use this functionality, consider the
following scenario: an application reads financial information from an XML file that is
periodically updated. The application processes the data in the file and creates a graph of
objects that represent that data in a consumable format. The application caches that data and
inserts a dependency on the file from which the data was read. When the file is updated, the
data is removed from the cache and the application can reread it and reinsert the updated copy
of the data.
Cache.Remove(“Key”)
2.The second and complext method is that if you want to control how ASP.NET decides which
items to remove from the cache, and when it does so, you need to provide ASP.NET with that
information when you add an item to cache.
You can set the priority of an item by passing one of the values of the CacheItemPriority
Enumeration when calling Add or Insert method.
You can also set the rate at which an item decays by passing one a value of the
CacheItemPriorityDecay Enumeration to Add or Insert method.
Cache.insert(key,item,CacheDependency,AbsoluteExpiration,SlidingExpiration,
CacheItemPrority.High,CacheItemPriorityDecay.Slow,Nothing)
CacheDependency--Nothing
AbsoluteExpiration-DateTime.Now.AddMinutes(20)- 2min:Expiration for two minutes
from the time when the item is added to the cache.
SlidingExpiration-Timespan.Zero
Nothingsets the call back function for the item to nothing.
What is Cache dependency?
It is a class that allows you to create a dependency for a cached item on more files or
Directories(file dependency) or on one or more Cache items(Kaydependencies).
The constructor for the CacheDependency Class has the following three forms.
‘Monitor a file or Directory for changes
Dim mydependency as CacheDependency
Mydependency=New CacheDependency(“myFile or Dirname”)
‘Monitor an array of file names and/or paths, and an array of keys for changes
Dim mydependency as CacheDependency
Mydependency=New CacheDependency(myFile or Dirarray,myKeyArray)
Inorder to setup a key dependency without any file dependencies , you must create an array of
keys(even if there is only one key) and pass Nothing as the first argument to the
contructor,passing the array of key as the second.
Once the instance of cache dependency has been created , it can be passed as a Parameter to Add
or Insert method of the Cache Class.
Cache.Insert(“MyDS”,myDs,myDependency)
NB:- Unlike Application and Session Collections which can be accessed by either key or
numeric index, cache item can only be accessed by their key.
What is the difference between Add and Insert Methods of Cache class?
7.SECURITY:-
How security takes place in ASP.NET Applications?
What is CodeAccessSecurity?
What is RoleBasedSecurity?
What is Authentication?
2.Password Authentication:-
Password Authentication used the Centralized Password service provided by Microsoft. Passport
authentication gives users a single login to use with any passport-enabled site.
In order to use Passport Authentication with ASP.NET , you must download and install SDK,
which is available with www.passport.com/business
<authentication mode=”passport”/>
<passport redirectUrl=”<url>”/>
<credentials PasswordFormat=”Clear|MD5|SHA1”>
<username=”username” password=”password”/>
</credentials>
</forms>
<passport redirectUrl=”url”/>
</authentication>
Secure Socket Layer Protocol request a server certificate and Register it.
Encryption is an important tool for keeping information secure.
The most commonly used form of encryption in web application is Secure Socket Layer
Protocol.
SSL is used by sites requiring secure communications between the webserver and browser to
create and exchange a key used to encrypt communications between the client and the server.
Its useful to protect credit card information, session id cookies and Login Information , when
using Basic Authentication or Asp.net Forms Based Authentication.
SSL Coomunication occurs at 443 port instead of 80 and http:// are used as https://.
What is Authorization?
Authorization is determining whether the user has permission to take the action required.
ACL’s based authorization is useful when you are using Windows Based Authentication in
ASP.NET.
With ACL-Based Authorization, you use tools such as properties dialog for a file or folder in
Windows explorer to set the list of users or groups that are allowed to access a given resource
and what rights(read,write,execute) each one has.
Advantages:-
1. It doesn’t requiring writing any security specific code in ASP.NET applications.
2. All are taken by Administrator only.
URL Based Authorization lets you grant or deny access to resources in your application based
on their URL using <authorization> tag in web.config.
NB:-Unlike <authentication> tag, this can be applied to subdirectories, even individual fields
also.
Wild cards:- * Allow/deny all users
? Allow/deny anonymous users
<authorization>
<allow users=”userlist” *,?,names
roles=”rolelist” administrators,users
verbs=”verblists”/ >GET/POST/HEAD/DEBUG
<deny users=”userlist”
roles=”roleslist”
verbs=”verbslist”/>
</authorization>
<Location allowOverride=”false”>
<authorization>
</authorization>
</location>
Path Attributes that allow you to specify the path to which the settings contains between
<Location> tags apply.
What is Impersonation?
Impersonation is the process by which ASP.NET takes on the security context of the user
making request. This allows ASP.NET to gain access to resources that the user is authorized to
use.
This can be conformed using <identity> tag without impersonation, ASP.NET runs as the
buit-in SYSTEM account.
<identity
impersonate=”true/false”
username=”username”
password=”password”>
What is CAS?
Code Access Security is the part of the .NET security model that determines whether or not a
piece of code is allowed to run , and what resources it can use when it is running. Hence it is
CAS that will prevent a .NET web applet from formatting your harddisk.
14.General:-
What is Boxing and Unboxing?
Boxing is a mechanism of converting a value type to reference type.
Un Boxing is a mechanism of Converting reference type to value type.
What are Different Object types offered by CLR?
There are two types of Object types that are offered by CLR. They are
c) Value Types
d) Reference Types
Reference Types are always allocated from the managed heap and the new operator returns the
memory address of object and Garbage collector take care of freeing of memory resources.
Eg: Strings,objects etc
Value Types are allocated on a thread’s stack and variable representing the object does not
contain a pointer to an object. Value types are lightweight than reference types because they
are not allocated in managed heap, not garbage collected and not referenced to by pointers.
Value type is referred as structure. value type is primitive type and type does not inherit from
another type.
Eg: int32,Boolean,decimal etc.
NB:-Heap is Temporary Memory i.e RAM and Stack is Permanent Memory i.e HardDisk.
What are delegates?
A delegate is a type safe reference to a function or method.
It is useful when you want to register a callback function that gets called when the user
selects a menu or when an un handled exception is thrown or you may want a function to be
called when an asynchronous operation completes its execution.
What are Custom Attributes?
Custom Attributes are used to adorn type,methods,fields etc.
When compiled the compiler emits these method attributes into the managed module’s
metadata. At runtime, this metadata can be examined and based on the presence of these
attributes the behaviour of the application changes.
What are Attributes?What are different types of Attributes?
Attributes are used to adorn type,methods,fields etc.
There are at least two types of .NET Attributes. They are
c) Metadata Attributes:-It allows some data to attached to a class or method. This data
becomes part of metadata for the class and can be accessed via reflection. Eg [serializable]
NB:-System.Attribute class
d) Context Attributes:-This also uses same syntax as Metadata Attributes but they are
fundamentally different. Context Attributes provide an interception mechanism whereby
instance activation and method calls can be pre and /or post processed.
What type of testing will you perform while designing and Developing Application?
The following are the some of the guidelines to create a good ASP.NET application.
Disable session when not using it. This can be done at the application level in the
"machine.config" file or at a page level.
The in-proc model of session management is the fastest of the three options. SQL
Server option has the highest performance hit.
Minimize the amount and complexity of data stored in a session state. The larger and
more complex the data is, the cost of serializing/deserializing of the data is higher
(for SQL Server and State server options).
Use Server.Transfer for redirecting between pages in the same application. This will
avoid unnecessary client-side redirection.
Choose the best suited session-state provider - In-process is the fastest option.
Avoid unnecessary round-trips to the server - Code like validating user input can be
handled at the client side itself.
Use Page.IsPostback to avoid unnecessary processing on a round trip.
Use server controls in appropriate circumstances. Even though are they are very easy
to implement, they are expensive because they are server resources. Sometimes, it is
easier to use simple rendering or data-binding.
Save server control view state only when necessary.
Buffering is on by default. Turning it off will slow down the performance. Don't
code for string buffering - Response.Write will automatically buffer any
responses without the need for the user to do it. Use multiple Response.Writes
rather than create strings via concatenation, especially if concatenating long strings.
Don't rely on exceptions in the code. Exceptions reduce performance. Do not catch
the exception itself before handling the condition.
// Consider changing this...
try { result = 100 / num;}
catch (Exception e) { result = 0;}
// to this...
if (num != 0)
result = 100 / num;
else
result = 0;
Use early binding in VB.NET and Jscript code. Enable Option Strict in the
page directive to ensure that the type-safe programming is maintained.
Port call-intensive COM components to managed code. While doing Interop try
avoiding lot of calls. The cost of marshalling the data ranges from relatively cheap
(i.e. int, bool) to more expensive (i.e. strings). Strings, a common type of data
exchanged for web applications, can be expensive because all strings in the CLR are
in Unicode, but COM or native methods may require other types of encoding (i.e.
ASCII).
Release the COM objects or native resources as soon as the usage is over. This will
allow other requests to utilize them, as well as reducing performance issues, such as
having the GC release them at a later point.
Use SQL server stored procedures for data access.
Use the SQLDataReader class for a fast forward-only data cursor.
Datagrid is a quick way of displaying data, but it slows down the application. The
other alternative, which is faster, is rendering the data for simple cases. But this
difficult to maintain. A middle of the road solution could be a repeater control,
which is light, efficient, customizable and programmable.
Cache data and page output whenever possible.
Disable debug mode before deploying the application.
For applications that rely extensively one external resource, consider enabling web
gardening on multiprocessor computers. The ASP.NET process model helps enable
scalability by distributing work to several processes, one on each CPU. If the
application is using a slow database server or calls COM objects that access external
resources, web gardening could be a solution.
Enumerating into collections sometimes is more expensive than index access in a
loop. This is because the CLR can sometimes optimize array indexes and bounds
checks away in loops, but can't detect them in for each type of code.
JScript .NET allows methods within methods - to implement these in the CLR
required a more expensive mechanism which can be much slower, so avoid them by
moving inner methods to be just regular methods of the page.
Do a "pre-batch" compilation. To achieve this, request a page from the site.
Avoid making changes to pages or assemblies that are there in the bin directory of
the application. A changed page will only recompile the page. Any change to the bin
directory will result in recompile of the entire application.
1.
The config file is configured to enable the widest set of features. For a performance
boost it is better to tune it to the requirements. Some key points here are:
Encoding - Request/Response - The default is UTF-8 encoding. If the site
is completely ASCII, change the option to ASCII encoder.
Session State - By default is ON. If session state is not maintained then the
value should be changed to OFF.
ViewState - Default is ON. Turn it off if not being used. If ViewState is
being used there are different levels of security that need to considered
which can impact the performance of the application.
AutoEventWireup - Turning off AutoEventWireup means that the page will
not try and match up method names to events and hook them up (i.e.
Page_Load, etc). Instead, if the application writer wishes to receive them,
they need to override the methods in the base class (i.e. override OnLoad for
the page load event instead of using a Page_Load method). By doing so, the
page will get a slight performance boost by not having to do the extra work
itself, but leaving it to the page author.
2.
For efficient debugging Use ASP.NET trace feature to debug instead of
Response.Write.
3.
Name some of the Microsoft Application Blocks. Have you used any? Which ones?
A. Examples:
Exception Management
Logging
Data Access
User Interface
Caching Application Block for .NET
Asynchronous Invocation Application Block for .NET
Configuration Management Application Block for .NET
(there are others) We use Exception and Data Access