Вы находитесь на странице: 1из 57

CONTENTS:-

1.Object Oriented Concepts


2.NET Framework.
3.Page
4.ASP.NET
5.Controls
6 Data Access Technologies.
7.Caching
8.SessionManagement
9.Security
10.General
11..Exceptions`1

1.OBJECT ORIENTED CONCEPTS:-

 What is Object Oriented Programming?


Object Oriented Programming is an approach that Provides a way of Modularizing programs
by creating Partitioned memory area for both data and functions that can be used as templates
for creating copies of such modules on Demand.
 What are the features of Object Oriented Programming?

1.Emphasis is on Data Rather than Procedure.


2.Data is hidden and can’t be accessed by external functions.
3.Programs are divided into what are known as Objects.
4.Objects may communicate with each other through methods.
 What are the Benefits of Object Oriented Programming?
1.Through Inheritance, we can eliminate redundant code and extend the use of existing classes.
2.We can build programs from the standard Working modules, rather than writing the code from
scratch. This leads to savings of Development time and gives Higher productivity.
3.The principle of Data hiding helps from invades by code in other parts of the program.
4.Easy to partition work in a project based on Objects.
5.Object Oriented systems can be easily updated from small to large Systems.
6.Software Complexity can be easily managed.

 What are the Basic Concepts of Object Oriented Programming?


Basic Concepts of OOPs are
1.DataAbstraction and Encapsulation.
2.Inheritence
3.Polymorphism.
 What is Data Encapsulation?
The wrapping up of data and methods into a single unit is called Encapsulation.
So data is not accessible to outside world and only those methods can access it.
This insulation of data from direct access by programs is called Data Hiding.
 What is Inheritance?
Inheritance is the process by which Objects of one class acquire properties of another class.
Inheritance Provides the idea of Reusability.
 What are different types of Inheritance?
1.Single Inheritance:- Only One Base class and One derived Class
2.Multiple Inheritance:- Several Base Classes and a single Derived class
But this possible only with Interfaces and not with Base classes as a class can atmost t extend a
base class but can Implements more than one interfaces.
3.Hierarchical Inheritance:-One Base Class and many derived classes.
4.Multilevel Inheritance:-Derived from derived class.

 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.
pWhat 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);
}

And Inclusion Polymorphism or Runtime Polymorphism(LateBinding)-Using Virtual


Methods –The decision of which method to call is delayed until Runtime.
Class Maruthi{public virtual void Display(){}}
Class Esteem:Maruthi{public override void Display(){}}
Class Zen:Maruthi{public override void Display(){}}
Class Inclusion{
Public static void Main(){
Maruthi m=new Maruthi();
m=new Esteem();
m.Display();
m=new Zen();
m.Display();
}
What are different types of Polymorphisms that are available
?
Runtime Polymorphism and Compile Polymorphism

 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?

Abstract Class Interface


1.May or maynot have abstract 1.Can only have abstract methods, but
methods. use virtual attribute in abstract Key word is not allowed.
class to implement Partial
Implementation.
2.Methods can have access modifiers. 2.no access modifiers are allowed,
(except Private Members.) implicitly Public..`
3.can have fields, Properties and 3.can have only final constants, Properties
Methods. and
Methods.
4.Can Extend a single class and 4.Can’t Extend a Class and can extend a
implement one single or multiple interfaces.
or more Interfaces.
*5.Abstract classes form part of the 5.Interfaces do not .we can use same
Inheritance schema. interface in two projects that are not related
interms of Inheritance.
6.Can Have Constructor. 6.Can’t Have Constructor.
*7.Its Speed and Fast at Execution. 7.Slow at Execution.
*8.If you are Designing Large 8.If you are designing small,Consise bits
Functional units of Functionality use Interfaces.
use an Abstract Class.
*9.If you want provide Common, 9.If the Functionality you are creating will
Implemented functionality among be useful across a wide range of Disperate
all implementations of objects
your Component, use an Abstract ,use an Interface.
Class.

 What are Delegates?


Delegate is a Type defining a method signature, so that delegate instances can hold and
Invoke method or list of methods that match its signature.
Delegates Provides Callback behavior in an ObjectOrientedType Safe Manner.
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.
Using of Delegate Invoke 4 steps as follows.
a)Delegate Declaration:-modifier delegate return_type delegate_name(parameters)
Modifier -new/static/override/abstract/sealed
eg. delegate void Mathop(double a, double b)
b)Delagate Method Defination:-
public static double Multiply(double a,double b)
{ return (a*b);}
public double Divide(double a,double b)
{return (a/b);}
c)Delegate Instantiation:-
new delegate_type(expression)
Mathop m=new Mathop(multiply);
d)Delegate Invocation:-
delegate_object(paramers list)
double d=Mathop(12.23,34.44);
 What is Event - Delegate?
An event is a Delegate type class member that is used by the Object or class to provide a
notification to other objects that an event has occurred.
Modifier event type event_name
Modifier -new/static/override/abstract/sealed
Public event Eventhandler click;---here type eventhandler is the delegate type.
When button is clicked the following code will be added in Initailized Component.
This.Button1.Click+=new System.EventHandler(this.Button1_Click)
The event keyword lets you specify a delegate that will be called upon the occurrence of some
"event" in your code. The delegate can have one or more associated methods that will be
called when your code indicates that the event has occurred. An event in one program can be
made available to other programs that target the .NET Framework Common Language Runtime.
 What is new Modifier?
New modifier is used to hide the base class method from derived class method. It allows to
reDefine some methods contained in Derived class.

 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.

 What are Constructors?


Constructors are Procedures that control Initialization of new instances of a class.
 What are Destructors?
Destructors are Procedures that are used to free System Resources when a class leaves a scope
or is set to nothing.
VB.NET—Finalizer;C#- Destructor
 What are References?
References allows you to use objects defined in Other Assemblies.
 What are Shared Members (VB)/Static Members(C#)?
Shared Members are Properties, Methods and Fields that are shared by all instances of the
class.
Sharing single instance of a data member or function among all instances of a class is useful in
applications that use Inheritance.
 What is Namespace?
Namespaces prevent naming conflicts by organizing classes, Interfaces and Methods into
hierarchies.
An assembly can contain one ore more namespaces.
Anyalternativeto avoid name collisions other then Namespaces.
A scenario that two namespaces named N1 and N2 are there both having the same class say A.
now in another class i ve written
using1;
usingN2;
and i am instantiating class A in this class. Then how will u avoid name collisions?
Ans:usingalias
Eg: using MyAlias = MyCompany.Proj.Nested;

 What are attributes?


Attributes enable you to provide additional Information about Program elements.
Eg. Access Modifiers .these can be used on class and members in the class like
variable,property,methods.
Method signature:
Attributes(opt) method_modifier(opt) return_type member_name(parameter_list opt)

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 are Me/MyBase/MyClass keywords?


Me keyword is used any time we want to refer to methods within the Current Object.
(this in C#)
Mybase keyword is used to call Parent Class method within the Subclass.
MyClass is used in a scenario , where the code Calls your own implementation of the
method instead of an overridden method in the derived class
 What is Over Loading?
Over Loading is the ability to define Properties, Methods that have the same name but use
different type of data types and different type of Parameters.
Overloading Procedures allow you to provide as many implementations as necessary to handle
different kinds of data while giving the appearance of a single Versatile procedure.
Functions of Same name but with different Parameters.
Simply by Changing return type we can’t Overload a method.
Overloads---Keyword-VB
NoKeyword-C#

 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#

 What is Distributed Computing?


It is a Programming Model in which processing occurs in Many Different Places around
the network eg. On a server, Personal Computer ,Hand held device.
This is contrast to the two node system prevalent today(The client and Centralized server).
 Which namespace is the base class for .net Class library?
system.object
using directive vs using statement?
You create an instance in a using statement to ensure that Dispose is called on the object when
the using statement is exited. A using statement can be exited either when the end of the using
statement is reached or if, for example, an exception is thrown and control leaves the statement
block before the end of the statement.
The using directive has two uses:
 Create an alias for a namespace (a using alias).
 Permit the use of types in a namespace, such that, you do not have to qualify the
use of a type in that namespace (a using directive).
 What is the difference between CONST and READONLY?
Both are meant for constant values. A const field can only be initialized at the declaration of the
field. A readonly field can be initialized either at the declaration or in a constructor. Therefore,
readonly fields can have different values depending on the constructor used.
readonly int b;
public X()
{
b=1;
}
public X(string s)
{
b=5;
}
public X(string s, int i)
{
b=i;
}
Also, while a const field is a compile-time constant, the readonly field can be used for runtime
constants, as in the following example:
public static readonly uint l1 = (uint) DateTime.Now.Ticks; (this can't be possible with const)
 What is the difference between ref & out parameters?
An argument passed to a ref parameter must first be initialized. Compare this to an out
parameter, whose argument does not have to be explicitly initialized before being passed to an
out parameter.
 What is the difference between Array and Arraylist?
As elements are added to an ArrayList, the capacity is automatically increased as required
through reallocation. The capacity can be decreased by calling TrimToSize or by setting the
Capacity property explicitly.
What is Jagged Arrays?
A jagged array is an array whose elements are arrays. The elements of a jagged array can be of
different dimensions and sizes. A jagged array is sometimes called an "array-of-arrays."
 What are indexers?
Indexers are Location indicators and are used to access class objects, just like elements in an
array. They are useful in cases where a class is a container for other objects.
An Indexer looks like a Property with two following differences.
1.Indexer takes an Index argument and looks like an Array.
2.Indexer is declared using the name this.
Indexers are similar to properties, except that the get and set accessors of indexers take
parameters, while property accessors do not.
Public double this [int idx]{get{}set{}}
Eg.class List{ArrayList array=new ArrayList();
Public object this[int index]
{get{return(array[index])}}
set{array[index]=value;}}}
class IndexerTest{public static void main()
{List list=new List();list[0]=”123”;list[1]=”abc”;
for(int I=0;I<list.count;I++)
Console.writeline(list[I])}}
 What are indexers?
Indexers are Location indicators and are used to access class objects, just like elements in an
array. They are useful in cases where a class is a container for other objects.
An Indexer looks like a Property with two following differences.
1.Indexer takes an Index argument and looks like an Array.
2.Indexer is declared using the name this.
Indexers are similar to properties, except that the get and set accessors of indexers take
parameters, while property accessors do not.
Public double this [int idx]{get{}set{}}
Eg.class List{ArrayList array=new ArrayList();
Public object this[int index]
{get{return(array[index])}}
set{array[index]=value;}}}
class IndexerTest{public static void main()
{List list=new List();list[0]=”123”;list[1]=”abc”;
for(int I=0;I<list.count;I++)
Console.writeline(list[I])}}
 What are Different DataTypes available in .NET?
1.In Value Type, the variable stores the Data directly in the Stack Memory. i.e
Structures,Enumerations.
2.In Reference Type,the Variable stores the Address of the Data and the Data is Stored in the
Heap Memory. and Garbage collector take care of freeing of memory resources.

i.e Class,Arrays,Interfaces,Delegate.

 What are Data Types available in .NET?

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.

What is Custom attribute? How to create? If I'm having custom attribute in an


assembly, how to say that name in the code?
A: The primary steps to properly design custom attribute classes are as follows:
a. Applying the AttributeUsageAttribute ([AttributeUsage(AttributeTargets.All,
Inherited = false, AllowMultiple = true)])
b. Declaring the attribute. (class public class MyAttribute : System.Attribute { // . . .
})
c. Declaring constructors (public MyAttribute(bool myvalue) { this.myvalue =
myvalue; })
d. Declaring properties
public bool MyProperty
{
get {return this.myvalue;}
set {this.myvalue = value;}
}
The following example demonstrates the basic way of using reflection to get access to
custom attributes.
class MainClass
{
public static void Main()
{
System.Reflection.MemberInfo info = typeof(MyClass);
object[] attributes = info.GetCustomAttributes();
for (int i = 0; i < attributes.Length; i ++)
{
System.Console.WriteLine(attributes[i]);
}
}
}

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
a) 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
b) 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 is early binding and late binding?


 Early binding means that the compiler has knowledge about an object at compile time
 Late binding means that compiler do not have any knowledge about an object
Late Binding uses Create Object to create and instance of the application object, which you
can then control.
Eg: Dim oXL as Object
Set oXL=CreateObject(“Excel.Application”)
NB: -Regardless of whether you are using early or late binding use GetObject to manipulate
an existing object.

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

Advantages of Late Binding:-


1.The main Advantage to use late binding is that the code is more certain to be version –
Independent.
2.In Early binding, the more references your project contains , the larger the file size and the
longer it takes to compile.
3.Some Programming environments don’t allow you to create references to another
application.

In which cases you use override and new base?


Use the new modifier to explicitly hide a member inherited from a base class. To hide an
inherited member, declare it in the derived class using the same name, and modify it with the
new modifier.
 What are Sealed Classes in C#?
The sealed modifier is used to prevent derivation from a class. A compile-time error occurs if a
sealed class is specified as the base class of another class. (A sealed class cannot also be an
abstract class)
 In which Scenario you will go for Interface or Abstract Class?

Interfaces vs. Abstract Classes


Feature Interface Abstract class
Multiple A class may implement A class may extend only one
inheritance several interfaces. abstract class.
An abstract class can provide
An interface cannot
Default complete code, default code,
provide any code at all,
implementation and/or just stubs that have to be
much less default code.
overridden.
Static final constants
only, can use them
without qualification in
classes that implement
Both instance and static
the interface. On the
constants are possible. Both
other paw, these
Constants static and instance intialiser code
unqualified names pollute
are also possible to compute the
the namespace. You can
constants.
use them and it is not
obvious where they are
coming from since the
qualification is optional.

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.

Interfaces are often used An abstract class defines the


to describe the peripheral core identity of its descendants.
abilities of a class, not its If you defined a Dog abstract
central identity, e.g. an class then Damamation
is-a vs -able or Automobile class might descendants are Dogs, they are
can-do implement the not merely dogable.
Recyclable interface, Implemented interfaces
which could apply to enumerate the general things a
many otherwise totally class can do, not the things a
unrelated objects. class is.

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.

If all the various If the various implementations


implementations share is are all of a kind and share a
Homogeneity the method signatures, common status and behavior,
then an interface works usually an abstract class works
best. best.

If your client code talks Just like an interface, if your


only in terms of an client code talks only in terms of
interface, you can easily an abstract class, you can easily
Maintenance
change the concrete change the concrete
implementation behind it, implementation behind it, using
using a factory method. a factory method.

Slow, requires extra


indirection to find the
corresponding method in
Speed the actual class. Modern Fast
JVMs are discovering
ways to reduce this speed
penalty.

The constant declarations You can put shared code into an


in an interface are all abstract class, where you cannot
presumed public static into an interface. If interfaces
final, so you may leave want to share code, you will
that part out. You can't have to write other bubblegum
call any methods to to arrange that. You may use
Terseness
compute the initial values methods to compute the initial
of your constants. You values of your constants and
need not declare variables, both instance and
individual methods of an static. You must declare all the
interface abstract. They individual methods of an
are all presumed so. abstract class abstract.

If you add a new method


to an interface, you must If you add a new method to an
track down all abstract class, you have the
Adding implementations of that option of providing a default
functionality interface in the universe implementation of it. Then all
and provide them with a existing code will continue to
concrete implementation work without change.
of that method.
 Write one code example for compile time binding and one for run time binding? What
is early/late binding?
An object is early bound when it is assigned to a variable declared to be of a specific object
type. Early bound objects allow the compiler to allocate memory and perform other
optimizations before an application executes.
' Create a variable to hold a new object.
Dim FS As FileStream
' Assign a new object to the variable.
FS = New FileStream("C:\tmp.txt", FileMode.Open)
By contrast, an object is late bound when it is assigned to a variable declared to be of type
Object. Objects of this type can hold references to any object, but lack many of the advantages
of early-bound objects.
Dim xlApp As Object
xlApp = CreateObject("Excel.Application")
pHow can you write a class to restrict that only one object of this class can be created
(Singleton class)?
Use the private access modifier for default constructor and use static getinstance method to
create an intenace, if already one is not present.
Difference between type constructor and instance constructor? What is static
constructor, when it will be fired? And what is its use?
(Class constructor method is also known as type constructor or type initializer)
Instance constructor is executed when a new instance of type is created and the class
constructor is executed after the type is loaded and before any one of the type members is
accessed. (It will get executed only 1st time, when we call any static methods/fields in the same
class.) Class constructors are used for static field initialization. Only one class constructor per
type is permitted, and it cannot use the vararg (variable argument) calling convention.
A static constructor is used to initialize a class. It is called automatically to initialize the class
before the first instance is created or any static members are referenced.
What is Private Constructor? and it’s use? Can you create instance of a class which has
Private Constructor?
A: When a class declares only private instance constructors, it is not possible for classes outside
the program to derive from the class or to directly create instances of it. (Except Nested classes)
Make a constructor private if:
- You want it to be available only to the class itself. For example, you might have a special
constructor used only in the implementation of your class' Clone method.
- You do not want instances of your component to be created. For example, you may have a
class containing nothing but Shared utility functions, and no instance data. Creating instances of
the class would waste memory.
 I have 3 overloaded constructors in my class. In order to avoid making instance of the
class do I need to make all constructors to private?
(yes)
 Overloaded constructor will call default constructor internally?
(no)
p What is check/uncheck?
p What is Asynchronous call and how it can be implemented using delegates?
p How to create events for a control? What is custom events? How to create it?
p without modifying source code if we compile again, will it be generated MSIL again?
What is Params/Ref/Out parameters?-Method Parameters
The params keyword lets you specify a method parameter that takes an argument where the number of
arguments is variable.

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:-

 What is .NET?(.NET Framework)


.NET is a new Environment for Developing and Running software Applications, featuring ease
of Development of Web based Services, rich standard runtime services available to Components
written in a variety of Programming Languages and Inter language interoperability.
 What is .NET Framework?
.NET Framework is a set of Technologies that are designed to transform Internet into a full-
scale distributed Computing Platform.
What are the new Technologies in .NET Framework? Or
What .NET Framework consists?
.Net Framework Consists of Two main Parts.
a).Common Language Runtime(CLR)
b) .NET Framework Class Library
 What is CLR?
CLR is a set of Standard Resources responsible for execution of Code developed using .NET
Languages.
CLR is a Replacement to win32 API.
 What CLR do?
CLR take care of
1.Memory Management
2.Thread Execution
3.CodeExecution
4.Code Safety Verification
5.Compilation
6.Automatic Garbage Collection
7.Very High Level Of Security while Executing

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.

 What Compiler do?


The compiler compiles the source code into Intermediate Language (Microsoft Intermediate
Language),Which is language Independent. Then it is compiled to native machine code.
 What is Microsoft Intermediate Language(MSIL)?
MSIL or IL is the CPU Independent Instruction set that is generated by Microsoft .NET
Framework Compilers and Consumed by .NET Framework’s Common Language Runtime.
Before MSIL can be executed, it must be converted to native CPU-Specific Code by
Common Language Runtime.
IL = Intermediate Language. Also known as MSIL (Microsoft Intermediate
Language) or CIL (Common Intermediate Language).

 What is the CTS?


CTS = Common Type System. This is the range of types that the .NET runtime
understands, and therefore that .NET applications can use. However note that not all .NET
languages will support all the types in the CTS. The CTS is a superset of the CLS.
 What is the CLS?
CLS = Common Language Specification. This is a subset of the CTS, which all .NET
languages are expected to support. The idea is that any program, which uses CLS-
compliant types, can interoperate with any .NET program written in any language.
In theory this allows very tight interlope between different .NET languages - for example
allowing a C# class to inherit from a VB class.
Performing Cross-Language Inheritance the Language Compilers must follow CLS.
CLS(Common Language Specification) describes a subset of Data types supported by Runtime,
that are common to all of the languages used in .NET.
 What are Data Types available in .NET?

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 UnManaged Code?


UnManaged Code is code that is executed directly by O.S, outside the Microsoft .NET
Framework’s Common Language Runtime. Unmanaged code must provide its own memory
management, typechecking and security support, unlike Managed code which receives these
services from Common Language Runtime. Unmanaged code must be executed outside the
.NET Framework

What is Managed Environment?


A Managed Environment is one which the Environment Provides Services such as Garbage
Collection, Security and Other Similar Features.
 What is Managed Code?
.NET Framework Provides Several Core Runtime Services to the Programs that run within it.
For eg: Memory Management, Cross-Language Integration, Automatic Lifetime Control of
Objects etc.
For these services to work the code must provide a minimum Level of Information to the
Runtime. Such a Code is called Managed Code.
All C# and VB.NET code is Managed by Default.
 What are Managed Classes?
These are Classes that the memory for Instances of the class is Managed by Garbage Collector
and the Class becomes a Fully Paid up member of .NET community with the benefits that
brings.
Eg: Benefit is proper interop with classes written in Other Languages.
Restriction is that a managed class can inherit from one base class only.
 What is an Assembly?
An Assembly Consists of one or more files( Dlls, exes, Html files etc) , which represents a
group of resources ,Type Definitions and Implementation of those Types.
An Assembly may also contain references to other assemblies.
What is Versioning in .NET ?
Each assembly has a four-part version number as a part of its identity. This version number is
essential to distinguish different versions of an assembly for the purposes of side-by-side.
The 4 part number will be in the following format.
MajorVersion.MinorVersion.BuildNumber.Revision
Assemblies of either of first two parts different are viewed as ‘Incompatible’.
If First two parts are same , but third is different , the assemblies are referred as ‘may be
compatible’.
If only fourth part is different , assemblies are declared as ‘Compatible’
NB:-This version policy can be specified via ‘The Application Configuration File’

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).

 What is .NET Class Library?

.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.

 What is garbage Collection?


Garbage Collection is a system by which Common Language Runtime takes responsibility for
managing the lifetime of Objects and heap memory that they occupy.

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);
}

protected void Dispose(bool disposing)


{
if (disposing)
{
// dispose managed resources
}
// dispose unmanaged resources

disposed = true;
}

#region IDisposable Members


public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
#endregion

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.

 Benefits of an Event-Driven Model versus a Linear Processing Model


If you have experience using Active Server Pages (ASP), you recognize that ASP is a linear
processing model. An ASP page is processed in a top-to-bottom sequence. Each line of ASP
code and static HTML is processed in sequence as it appears in the file. User actions cause the
page to be posted to the server in a round trip. Since this action causes a round trip, the server
must recreate the page. After the page is recreated, it is processed in the same top-to-bottom
sequence as before, and therefore the page is not exhibiting truly event-driven behavior. To
create an event-driven experience, you need to explicitly design it. In addition, you have to
explicitly maintain page and control state at the most basic level. This model limits the richness
of the user interfaces that can be assembled, and it increases the complexity of the code needed
to support it.
In comparison, an event-driven model, as in a traditional Visual Basic application, contains
programmable elements that are initialized and displayed on the form. Users interact with the
elements, which cause events to be raised that in turn call event handlers. This model supports
true event-driven behavior, which, by design, greatly extends the richness of the user interfaces
that can be assembled, and it reduces the complexity of the code needed to support it.
ASP.NET replaces the linear processing model of ASP by emulating the behavior of an event-
driven model. The ASP.NET page framework is provided to implicitly make the associations of
an event to an event handler for you. Using the page framework allows you to easily create a
user interface that reacts to user actions. For details on creating and using events and event
handlers, see Server Event Handling in Web Forms Pages.
In addition, this same framework eases the implementation of page and control state
management. For more information on state management, see Web Forms State Management.
For example, ASP.NET allows you to set up event handlers in server code for events that are
passed from the browser. Assume the user is interacting with a Web Forms page that contains
one button server control. The user clicks the button control and an event is raised that is
transmitted via an HTTP post to the server where the ASP.NET page framework interprets the
posted information and associates the raised event with an appropriate event handler. This event
handler can be a default handler supplied by ASP.NET or it can be your custom implementation.
The framework automatically calls the appropriate event handler for the button as part of the
framework's normal processing. As a result, you no longer need to explicitly design event-like
behavior into a linear processing model. For more information on Web Forms event handling,
see ASP.NET Server Control Event Model
What are the different Stages in Page Processing?
The first time that an ASP.NET Web form page is executed, the code contained within the
page(and any code-behind class associated with the page) is compiled into a class that inherits
from the Page base class. Once compiled, the class is executed , the resulting HTML is rendered
to the browser and the class is removed from memory.
During this the Web Forms Page goes through different stages. They are
1.Init:-Page and Control settings are Initialized as necessary for the request.
2.LoadViewState:-Server control state that was saved to ViewState in an earlier request is
restored.
3.LoadPostData:-Any data returned in Server Control form fields is processed and the relevant
Control Properties are updated.
4.Load:-Controls are Created and Loaded, and Control state matches the data entered by the
client.
5.RaisePostDataChanged Event:-Events are raised in response to changes in control data from
previous request to current request.
6.RaisePostBackEvent:-The event that caused the Post Back is handled and the appropriate
Server-side events are raised.
7.PreRender:-Any Changes that need to be made prior to Rendering the page are processed.
Any Processing after this point will not be rendered to the page.
8.SaveViewState:-Server Control State is Saved back to the Page’s View State prior to tearing
down the controls.
9.Render:-Control and Page Output is rendered to the client.
(Dispose Stage:- in which References to Expensive resources such as database connections
must be released in this phase. Here Dispose Method is used)
10.Unload:-The Page and its Constituent Controls are removed from memory on the server.
Of These Stages in which stages we can handle Events?
Of These Stages you can add Page Level Event Handler for Init, Load, Pre Render and
Render Stages.
For other Stages such as, LoadViewState, SaveViewState ,LoadPostData
,RaisePostDataChangedEvent,RaisePostBackEvent Stages you can override the appropriate
method to customize the processing of these stages.
What is PostBack?
Post Back is the process by which a Web Form Page submits an Http Post Request to itself in
response to some User action.
How do u handle PostBack?
LoadPostData and RaisePostDataChangedEvent are methods of the IPostBackDataHandler
interface, and RaisePostBackEvent belongs to the IPostBackEventHandler interface. If your
control participates in postback data processing you must implement IPostBackDataHandler.
If your control receives postback events you must implement IPostBackEventHandler.
NB:-The CreateChildControls method is not listed in the table because it is called whenever
the ASP.NET page framework needs to create the controls tree and this method call is not
limited to a specific phase in a control's lifecycle. For example, CreateChildControls can be
invoked when loading a page, during data binding, or during rendering.

3.ASP.NET:-

What is the process-flow for ASP.Net?

1. User requests an ASPx page in their browser

2. An HTTP requests is sent to IIS

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.

9. Resulting HTML is sent to the browser

10. The process continues in a continual "Post Back" cycle.


What are HTTP Modules?

Definition of HTTP Modules: (ISAPI : Internet Service Application Programming)


HTTP modules are a logical replacement for ISAPI filters. Modules are a class that can
participate in every web request. This is appropriate for code that should run on every
request, such as caching, authentication or state management
What are HTTP 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.

What an Asp.net Web Application Consists?

A simple ASP.NET Web Application Consists of Four Things.


1.A virtual Directory in IIS , configured as an Application Root, to hold the files that make up
the application and to control access to the files.
2. One or more .aspx files.
3. A Global.asax file that is used to provide Application and Session Startup and Cleanup
code.
4. A Web.Config file used to store configuration Settings.
What Global.asax Contains?
The Global. asax file, also known as the ASP.NET application file, is an optional file that
contains code for responding to application-level events, session-level events and
CustomHttpModules events raised by ASP.NET.Global.asax file resides in the root directory of
an ASP.NET based application.
Global. asax is a file used to provide Application and Session Startup and Cleanup code.
The following Tasks can be performed in Global.asax
1.Respond to selected Application and Session Events.
a)Application_OnStart :Event is fired when first Request for any .aspx page is received.
This even is used to
a). Initialize Application Variables.
b).To execute Startup Code.
b)Session_Onstart: Event is fired, When a request comes from a user who does not have a
current session in Application Current Session is identified by SessionID cookie..
This even is used to
a). Initialize Session -level Variables.
b).To execute per user Startup Code.
c)Application_BeginRequest
d)Application_EndRequest
e)Session_OnEnd
f)Application_OnEnd
2.Respond to Events of Custom HttpModules you have created for applications.
NB:- HttpModules are Classes that inherit the IHttpModule interface and Participate in
Processing ASP.NET Requests.
3.Import Namespaces into the application using @Import Directive.
So without need of Import Namespace in each page and without having to fully qualify the
member Names.
NB:- If two or more Namespaces contain same members then must use Fully qualified member
names to avoid conflicts.
4.Register Assemblies for use in Your application using @Assembly Directive.
5.Create Instances of application level objects using <Object runtat=”server”> tag syntax.
<object runat=”server” id=”MyclassInstance” class=”Myclassname”
Scope=”Application/Session/AppInstance” >

In webformspage it can be used like this


MyVar=MyclassInstance.MyValue
Limitations:-

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.

2. Any Components Instantiated in <object> Tag should be multithreaded.


3.Objects created with <object > tag are not Instantiated immediately, but at the time when first
they are called.
What Web.config Contains?
Web.Config is an XML-Based human and machine readable file that contains the configuration
options for the Application. Its Optional, since Machine.Config exists.
When you add web.config to your application root, the configuration settings contained in that
file will apply throughout your application. You can also override these settings in specific areas
of your application by setting child folders in your applications.
Some of Configuration Options are
a) HttpModules and HttpHandlers:- Process specific types of requests and are similar to
ISAPI filters.
b)Session Settings:-Determines whether session settings are Improves, Out Of Process(Shared
Across Multiple Machine) or Stored by SqlServer.
c)Browser Capabilities:- Customize properties returned by HttpBrowserCapabilities Class
when it encounters a given browser.
d)Security:- Determines settings for Authentication, Authorization and Identity.
e)Compilation:-Determine settings used for Copiling the code in ASP.NET application
,Including which external assemblies are included in the compilation of the application
What is Different ways of working with ASP.NET?
There are 3 ways to work with ASP.NET.
1.Inline Code that is compiled on the web server as it is needed.
2.Code-behind Files that are compiled into .dll file and then removed from production.
3.Code-behind file that are compiled on the web server as they are needed.

What is Code Behind?


Code behind is a new feature in ASP.NET that allows developers to truly separate HTML UI
code from code in VB.NET.

What are the advantages of Code Behind?

a) Clean separation Of HTML and Code.


b) Easier Reuse.
c) Simpler Maintenance.
d)Deployment Without Source Code
 What happened to date () and time ()?
In ASP.Net you should use:
System.DateTime.Now.ToShortDateString () and
System.DateTime.Now.ToShortTimeString ()
 What are major differences between ASP.NET and ASP?
1.Current Versions of ASP supports only scripting Languages. This means that developers move
section of code to COM objects to get compiled and early bound support.
ASP.NET strongly supports Compiled languages. Compiled code means that all the variables
must have to be declared. so all objects are early bound.
2.In the Current version of ASP deploying COM objects is difficult. IIS keeps DLL loaded in the
memory forcing to shutdown all MTS packages.
ASP.NET provides support to manage and restart components that are in use when there is a
overload. This prevents memory leak from soaking up the resources.

 What are the advantages of ASP.NET over Classic ASP?


1.Clean Separation between the application logic(Server-side code) and the Presentation
layer(HTML markup)-no mixed code.
2.application server-side is compiled for better performance.
3. Application logic can be written in any Microsoft .net Language (VB,C#).
4.A Rich set of Server Controls that automatically render HTML suitable for any clients and
additionally manage their states.
5.Enhanced Session-State Management.
6.An Event-Based programming model on the server side , which is simple and more intuitive.
7.Visualstudio.NET as a RAD tool, which simplifies the development process of web Forms.
 About ASP Evolution?
ASP 1.0 available as an add on for IIS 3.0.The combination of ASP and ADO was fast and
effective.
ASP2.0 was a part of windows nt 4.0
Main Difference between ASP1.0 and ASP 2.0 was the instantiation of external components
presence of MTS made it easy to build components that can per take in Transactions.
ASP 3.0 Come along with windows2000. Its major difference with ASP was with COM.
Microsoft combined MTS with core COM to pertake in transactions. MTS Provides better
environment for components to be executed within and isolated process.
 What are major differences between ADO.NET and ADO?
In ADO, The in-memory representation of data is the recordset.
In ADO.NET ,it is dataset. There are important differences between them.
1.A Record set looks like a single table. Record set by nature is not able to represent multiple
tables without the use of DataShapeProvider.In contrast, a dataset is collection of one or more
tables. The tables in dataset are called DataTables. If the dataset contains data from multiple
database tables, it will typically contain multiple DataTable Objects. That is each DataTable
Object typically corresponds to a single database table or view. In this way dataset can mimic
the structure of the underlying database.
2.A dataset usually contains relationships, where as Recordset can’t contain any relationships.A
relation ship within a dataset is analoguous to a foreign-key relationship in a database. Hence
dataset can hold much richer structures than a recordset.
3.Minimizing Open Connections:-In ADO.NET connections are opened only long enough to
perform a database operation, such as a select or update. You can read rows into a dataset and
then work with them without staying connected to the data source. In ADO the record set can
provide disconnected access, but ADO is designed primarily for connected access.
4.In ADO, you communicate with database by making calls to an OLEDB Provider, While in
ADO.NET you communicate with the database through a data adapter. The important difference
is
that in ADO.NET the data adapter allows you to control how the changes to the dataset are
transmitted to the database-by optimising for performance, performing data validation checks, or
adding any other extra processing.
4.Sharing Data Between Applications:-Transmitting an ADO.NET dataset between
applications is much easier than transmitting an ADO disconnected record set. To transmit an
ADO disconnected record set from one component to another, you use COM Marshalling. To
transmit data in ADO.NET , you use dataset, which can transmit an XML Stream.
Transmitting of XML files offers the following advantages over COM marshalling.
a) Richer Data types:- COM marshalling provides a limited set of data types ,but there is
no restriction of data types in XML.
b) Conversion of Data type is needed in Com Marshalling, where In XML Stream its not
needed, which accounts to good performance.
c) Penetrating Firewalls:-Record sets can’t penetrate firewalls as XML streams do, since
Firewalls are designed to allow HTML text to pass, but to prevent system-level requests
from passing.

NB:-Record set was not XML-based and could not be serialized to XML easily or flexibly.

 How should I destroy my objects in ASP.Net?


ASP.Net actually has very solid internal garbage collection so this should not be an issue as it
was in previous versions of Active Server Pages.
 What is the difference between Server.Transfer and Response.Redirect?
Server.Transfer is the method you use to redirect the user to another page
without performing a round trip to the client.
Why would I choose one over the other?
 Can you explain the difference between an ADO.NET Dataset and an
ADO Recordset?
In ADO, The in-memory representation of data is the recordset.
In ADO.NET ,it is dataset. There are important differences between them.
1.A Record set looks like a single table. Record set by nature is not able to represent multiple
tables without the use of DataShapeProvider.In contrast, a dataset is collection of one or more
tables. The tables in dataset are called DataTables. If the dataset contains data from multiple
database tables, it will typically contain multiple DataTable Objects. That is each DataTable
Object typically corresponds to a single database table or view. In this way dataset can mimic
the structure of the underlying database.
2.A dataset usually contains relationships, where as Recordset can’t contain any relationships.A
relation ship within a dataset is analoguous to a foreign-key relationship in a database. Hence
dataset can hold much richer structures than a recordset.

4.CONTROLS:-

What are Different Types of ASP.NET controls ?


 HTML controls : They represent standard HTML controls but run at server end.
 Web Controls : ASP.NET offers a set of controls which map closely to standard HTML
controls but provide consistant properties, methods and events. Some WebControls like
data grid provide advance features which are not available with standard HTML controls

The common HTML controls


 <table>
 <tr>
 <td>
 <form>
 <input>
 <select>
 <textarea>
 <button>
 <a>
 <img>

The common Web Controls


 <asp:Button>
 <asp:TextBox>
 <asp:CheckBox>
 <asp:RadioButton>
 <asp:DropDownList>
 <asp:ListBox>
 <asp:Label>
 <asp:Panel>
 <asp:Table>
 <asp:TableRow>
 <asp:TableCell>
 <asp:Image>
 <asp:HyperLink>
 <asp:Repeater>
 <asp:Calendar>
There are also some advance controls like Input validation controls and data bound grid .
What are Validation 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.

The Different types of Validation Controls are:


1.RequiredFieldValidator
2.CompareValidator
3.RangeValidator
4.RegularExpressionValidator
5.CutomValidator
6.ValidationSummaryValidator
NB:-page.isvalid
Control Validation Property
HtmlInputText value
HtmlTextArea value
HtmlSelect value
HtmlInputFile value
TextBox Text
ListBox SelectedItem.Value
DropDownList SelectedItem.Value
RadioButtonList SelectedItem.Value
What are the Advantages of Server side Controls?
 Your code structure becomes clean and more readable
 Seperatation of processing code and display code is possible
 To access the values of the controls you no longer need to use Request collection, you
can refer to the control by its id directly
 The problem of state maintenance is automatically taken care by ASP.NET
 Web server controls provide a higher level of abstraction than HTML controls because
the Object model matches closely with .NET Framework.
 Web server controls provide richer functionality , such as the Calendar control, Ad
Rotator Control and so, on which are not available in HTML controls.
 Web server controls have advanced features such as automatic browser detection,
automatic post back and event bubbling.

How do you Make control run at server?


To process HTML or Web control you need to add runat="server" attribute the control
defination.
e.g.<input type="text" id="text1" runat="server">
<asp:TextBox id="text1" runat="server />

How ASP.NET maintains state?


ASP.NET uses hidden fields to maintain state of your controls. Hidden fields are used to store
values entered by the user into the form controls. There are some points which you should note
about state maintenance :
 Your FORM must run at server i.e. you must set runat attribute of FORM element to
"server"
You must use POST method. This is because if you use GET the data will be passed as query
string.

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.

How Server-side Event Processing Takesplace?


Server side controls have events that are processed at server end. Here again you set the runat
attribute of SCRIPT element to "server". The server side events have different naming
convention to seterate them from client side events.Each event is of the form OnServer<event>
e.g. OnSeverClick
e.g
<SCRIPT language="VB" runat="server">
Sub MyProc(sender as object,evt as EventArgs)
text1.value = "Hello From ASP.NET"
End Sub
</SCRIPT>
<INPUT type="text" value="" runat="server" id="text1>
<INPUT type="submit" value="Submit" runat="server" onserverclick="MyProc">
NB:-

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?

ASP.NET allows you to extend its functionality in two main ways :


 HttpHandlers
 HttpModules
Http handlers are special applications that typically handle files with certain extension. For
example when you request a file with extension .asp IIS routes it to ASP processor. But what if I
want to handle files with my own extensions say .bipin? Http handlers allow us to do just that.
Now, you might be thinking what is the use of a new file extension? Consider a case where you
want to generate graphics on the fly. In such cases you will write an Http handler that will do
your task. Note that Http handlers are typically called for the specific file extensions they are
designed for. If you have worked with ISAPI extensions in past you will find this concept very
familiar.
Http modules are similar to Http handlers in that they allow you to tweak with the request
and response. However, they are typically executed for every request irrespective of the file
type. If you have worked with ISAPI filters before you will find this concept very familiar.
What are User Controls?
A User Control is an extension of the functionality of an existing server controls.
Server controls that are shipped with .NET Framework, is a compiled DLL file and cannot be
edited. But it can be manipulated through its public properties at design-time or runtime. It is
possible to build a Custom Server Control.
What is difference between Web User Control and Web Custom Control?

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.

What are the values in the SqlConnection.ConnectionString?


The following table lists the valid names for values within the ConnectionString.
Name Default Description
Application Name The name of the application,
or '.Net SqlClient Data
Provider' if no application
name is provided.
AttachDBFilename The name of the primary
-or- file, including the full path
name, of an attachable
extended properties database.
The database name must be
-or-
specified with the keyword
Initial File Name 'database'.
Connect Timeout 15 The length of time (in
-or- seconds) to wait for a
connection to the server
Connection Timeout before terminating the
attempt and generating an
error.
Connection Lifetime 0 When a connection is
returned to the pool, its
creation time is compared
with the current time, and
the connection is destroyed
if that time span (in seconds)
exceeds the value specified
by connection lifetime.
Useful in clustered
configurations to force load
balancing between a running
server and a server just
brought on-line.
Connection Reset 'true' Determines whether the
database connection is reset
when being removed from
the pool. Setting to 'false'
avoids making an additional
server round-trip when
obtaining a connection, but
the programmer must be
aware that the connection
state is not being reset.
Current Language The SQL Server Language
record name.
Data Source The name or network
-or- address of the instance of
SQL Server to which to
Server connect.

-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

How State is maintained in Rich Client Applications?


Simply by allocating space in memory on the client machine, hence it is simple to maintain
Individual state.
Why maintaining State is difficult in Web Applications?
Since HTTP Protocol, which is used to send or receive requests through a web browser, is
inherently Stateless. So HTTP doesn’t inherently provide a way for web server to identify a
series of requests as coming from the same user, hence Maintaining state with as individual user
is difficult.
What is Application State?
It Refers to any data that need to share among multiple users of an Application.
e.g. Connection Strings, Shared Variables, Cached Datasets etc.
NB:- In general Connection Strings are stored in Web.Config and getConfig method of Context
Object is used to retrive them and Cached datasets are saved using ASP.NET caching Engine and
Shared variables that are shared and updated frequently are stored In Database.
How Application State can be stored?
Basically Application State is maintained using Collection of Key-Value pairs
There are three ways to store Application State. They are
a) By using Application Object
Application (Key)=value
b) By Using Application. Contents Collection
Application. Contents (Key)=Value

NB:-Application State Storage in ASP.NET is supplied by the .NET HttpApplication State


Class. An Instance of which is exposed as the Application Property of the Page Class.
c) By using Application. Add or Remove Methods
Application. Add(Key, Value)
Application. Remove (Key)
Application. Clear ()
Application.RemoveAll ()

What are the Properties and Methods of an Application Object?


Properties:-
AllKeys Property : Returns Collection of All keys by which Application Collection Values can
be accessed.
Count Property :Returns the number of Objects Stored in the Application Collection.
Methods:-
Get Method:-Returns an Item from the application Collection by Key or by Index.
Set Method:-Updates an Item in the Application Collection by Key or by Index.
GetKey Method:-Returns the key for an item based on supplied index.
ToString Method:-Returns a string that represents an item in the Application collection .Useful
when a string value is required rather than an Object Reference.
How Access to Application State is Synchronized? Or What are the cautions to be
taken while maintaining Application State?
Ensure that no two users can attempt to update the state information simultaneously, which lead
to corruption of data being processed. For this ASP.NET Application Object provides Lock and
Unlock methods.
Eg. Application. Lock(), Appliaction.Unlock(0
But this can cause scalability problems. For this ensure to keep application Locked for short
time possible.
NB:- References to Object Instances with Wrong threading model(COM) have severe Scalability
Problems.
What are Limitations of Application State?
1.Durability:-When WebApplication /Webserver shutdowns or crashes state information will be
destroyed.
2.Application State is not shared across in Webfarms and Web Gardens.
3.Memory:-Overuse of Application State may result in Information being swapped to virtual
memory,that can reduce performance significantly.
What is WebFarm?
Groups of Identically configured servers that share the load of Serving user requests for a given
web application.
What is WebGarden?
Through WebGarden , an Application can be set to run on specific Processor or Multi Processor
server.
What is SessionState?
Session State is Per User State Storage.
How Session State can be stored?
Basically Session State is maintained using Collection of Key-Value pairs
There are two ways to store Session State. They are
a) By using Session Object
Session(Key)=value
Eg. Session(“MyVar”)=”MyValue”
Mylocalvar=session(“Myvar”)
b) By Using Session. Contents Collection
Session.Contents (Key)=Value
Eg. Session.Contents (“MyVar”)= ”MyValue”
Mylocalvar=session.contents(“Myvar”)

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.

Dim myAbsUrl as string


MyAbsUrl=Response.ApplyAppPathModifier(“foo.aspx”)

What are Persistent and Non-Persistent Cookies?


Persistent cookies will persist across multiple browser sesions.
Non-Persistent Cookies persist to a single browser session.
NB:-
1.Never store sensitive data like credit card details in Cookies.
2.Keep expiration of cookies to reasonable time.

Mycookie.Expires=Now.address(2)
How Cookies are declared?

Dim mycookie as new HttpCookie(“Mycookiename”)


Mycookie.value=”Myvalue”
Response.Cookie.add(mycookie)
--Response.appendcookie(cookie)
What is Viewstate?
It’s a Mechanism through which All ASP.NET Server controls are capable of maintaining their
own state between Requests.It is maintained on a page by page basis as a hidden that contains all
the state information for all the form elements on that page.HTML controls won’t provide any
view state.
What is Caching?
Caching is the process of temporarily storing expensive resources in memory.These
Resource may be expensive because the amount of processor time necessary to render them as
they may reside on disk or in a backend database on another machine.
What are the different types of Caching available?
ASP.NET has three kinds caching that can be used by WebApplications.
a)Output caching:-Which caches dynamic response generated by request.
b)Fragment Caching:-Which caches portions of a response generated by a request.
c)DataCaching:-Which caches arbitrary Objects programatically.To support this ASP.NET
provides a full featured CacheEngine that allows programs to easily retain data across requests.
What are attributes of Output Caching ?
Duration:- Number of seconds to Cache the content.
Location:-Sets the location to be used to the cache content. It can be Client, server,downstream
None or Any. In client the content is cached by the requesting Client’s Browser. In server
contents are Cached on the webserver.In Downstream content can be cached by any cache –
aware application downstream of the webserver fulfilling the request.(ProxyServer).In any
content can be cached one of the above.And in none content is not at all cached.

What are attributes of Fragment Caching ?

VaryByParam:-Allows varying of Cached content based on the values of one or more


querystring values sent with a GET request, or form fields sent with a POST request.
Multiple key or field names are separated by Semicolon.
And * is set to vary by all parameters and none is used to use the same page regardless of
GET/POST parameters.

<%@ OutPutCache Duration=”120” VaryByParam =“Categoryid;selectedid”%>

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.

When Output Caching is used?


Output caching is useful when the contents of an entire page can be cached. On a heavily
accessed site, caching frequently accessed pages for even a minute at a time can result in
substantial throughput gains. While a page is cached by the output cache, subsequent
requests for that page are served from the output page without executing the code that
created it.
When Output Cache is enabled , an output cache entry is created on the first GET request
to page.Subsequent GET/HEAD requests are served from this entry until cached time
expires.
NB:-ASP.NET is a Compiled Language rather than interpreted language, which
increases performance. Hence these applications are always faster than classic ASP.
When Fragment Caching is used?

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.

What is 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.

Note that a file dependency is added by using Cache.Insert and supplying a


CacheDependency object referencing the XML file.
Cache.Insert("MyData", Source, _
New CacheDependency(Server.MapPath("authors.xml")))
A cache item can depend on a single or multiple files or keys. As mentioned previously, an
application can also set expiration policy on a cache item. The following code sets an
absolute cache expiration time.
Cache.Insert("MyData", Source, null, _
DateTime.Now.AddHours(1), TimeSpan.Zero)
The relevant parameter is the call to DateTime.Now.AddHours(1), which indicates that the
item expires 1 hour from the time it is inserted. The final argument, TimeSpan.Zero
indicates that there is no relative expiration policy on this item.
The following code shows how to set a relative expiration policy. It inserts an item that
expires 20 minutes after it is last accessed. Note the use of DateTime.MaxValue, which
indicates that there is no absolute expiration policy on this item.
Cache.Insert("MyData", Source, null, DateTime.MaxValue, _
TimeSpan.FromMinutes(20))

How Caching is removed?


There are two ways to remove cache from memory.
1.Remove an item from cache Programmatically by calling the Remove method of the Cache
Class and passing the key of the item to be removed. This is simple one and ASP.NET actually
do it for you.

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 do so by using Add or Insert methods of the Cache class.


ASP.NET determines the order in which items are scavenged from the cache based on their
Priority. Overtime if an item is not accessed ASP.NET will reduce its priority periodically.when
its priority reaches a predetermined point , it may be scavenzed.

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
Nothingsets 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 for changes


Dim mydependency as CacheDependency
Mydependency=New CacheDependency(myFile or Dirarray)

‘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.

Dim Keys(0) as String


Keys(0)=”mykeyname”
Mydependency=New CacheDependency(Nothing,Keys)

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?

Both provides essentially the same functionality, with two differences.


The first difference is that all parameters of Add method are required. So even If you are not
using a Particular parameter ,you must still pass a placeholder parameter.
The Insert method is Overloaded, which makes this method easier to use when you want to pass
only some of possible parameters.
The second difference is That the Add method returns an object that represents the item just
added to the Cache, while the insert method doesn’t return a value.

7.SECURITY:-
How security takes place in ASP.NET Applications?

IIS(Internet Information Server) authenticate all web requests.If ALLOWANONYMOUS is


turned on , no authentication occurs.IIS authorizes clients requests and returns appropriate
resource.In addition to built in ASP.NET Security features an ASP.NET assplication can also
use the Low-level security features of .NET Framework.(i.e CodeAccessSecurity and
RoleBasedSecurity), hence if you request a URL containing ASP.NET application,the request
and authentication information are handed off to the application.

What is CodeAccessSecurity?

What is RoleBasedSecurity?
What is Authentication?

Authentication is Determining the identity of the User Making a Request.

What are Different Types of Authentications Available?


NB:- Authentication and Authorization work in hand in hand to Operate on 2 Distinct
Levels.They are i. OS/IIS Level ii. ASP.NET Level

There are 3 Basic types of Authentication Available for ASP.NET Applications.


a) Windows Based Authentication
b) Passport Authentication
c) Form Based Authentication

1.Windows Based Authentication:-

In Windows Based Authentication ASP.NET Relies on IIS to authenticate Incoming request


using one of its available Authenticate Methods.

a) Basic Authentication:-Basic Authentication is Compatible with most browsers. But


Password is sent in Clear Text. These are Protected with SSL Encryption.
b) Digest Authentication:- Digest Authentication is introduced with HTTP 1.1,So it may
not support all browsers. It sends hashed value instead of Clear-Text Password, its more
secure than Basic Authentication. But it requires a Windows 2000 Domain Controller.
c) Integrated windows (NTLM) Authentication:-Integrated Windows Authentication is
Available only with Internet Explorer.Its most secure method because it never sends a
username /Password over the network., but it will not work over HTTP Proxy
Connection.
In Web.config it is set as
<authentication mode=”windows”/>
<identity impersonate=’true”/>

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>”/>

3.Form –Based Authentication:-(Cookie Athentication)

Form-Based Authentication allows developers to easily implement “rool-your-own” security


in their Applications. All you need to do is create the login page, tell ASP.NET where to find
(via web.config) and set the desired Authorisation restrictions. In your login page, you can
verify username and password credentials entered by user against a database, windows 2000
autrhenticate directory.
Once Credentials are verified you can use methods exposed by Forms Authentication class
to set or remove an authentication cookie redirect the user to original page they requested or
renew the authentication Cookie.

AUTHENTICATION TAG in WEB.CONFIG


<authentication mode=”windows|Forms|Passport|None”>
<forms loginurl=”url”
name=”name”
path=”/”
protection=”All|None|Encryption|Validation”
timeout=”number”(min)>

<credentials PasswordFormat=”Clear|MD5|SHA1”>

<username=”username” password=”password”/>
</credentials>
</forms>
<passport redirectUrl=”url”/>
</authentication>

What is SSL? When Its used?

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.

What are Different Types of Authorizations Available?

Authorization in ASP.NET takes two major forms.


I . Authorization Against NTFS Access Control Lists(ACLs)
II. URL Based Authorization

I. NTFS ACL’S For Authorization:-

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.

II. URL Based Authorization:-

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.

How CAS works?

The CAS Security policy revolves around two key concepts.


a) code groups
b) Permissions
Each .NET Assembly is a member of a particular code group and each code group is granted
the permissions specified in a named permission set.

Using caspol we can define our own permission sets.

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 is early binding and late binding?


 Early binding means that the compiler has knowledge about an object at compile time
 Late binding means that compiler do not have any knowledge about an object
Late Binding uses Create Object to create and instance of the application object, which you
can then control.
Eg: Dim oXL as Object
Set oXL=CreateObject(“Excel.Application”)
NB:-Regardless of whether you are using early or late binding use GetObject to manipulate
an existing object.
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

Advantages of Late Binding:-


1.The main Advantage to use late binding is that the code is more certain to be version –
Independent.
2.In Early binding, the more references your project contains , the larger the file size and the
longer it takes to compile.
3.Some Programming environments don’t allow you to create references to another application.

Differentiate between FullyQualified Vs Relative URLs?

There are 2 types of URLs used for creating hyperlinks in webpages.


1.FullyQualified URLs(Absolute URLs) and 2.Relative URLs.
Absolute URLs contain all information necessary for the browser to locate the resource named
in the URL. This includes the protocol moniker(http://,ftp:// etc),server’s domain name or IP
address and the path to the resource.
Relative URLs provide only the information necessary to locate a resource relative to the current
document(known as document relative) or current server or domain(known as root relative).
Because some controls or applications may not know how to use relative URLs, there may be
times when you need to use a fully qualified URL.
What is IIS?
Microsoft Internet Information Server is a webserver that enables to publish information (on A
corporate Intranet or) on the Internet.
To whom will you report regularly?
Team Leader.
Architecture of an Organization:-
Project Manager-Project Leader - Team Leader or Module Leader
Onsite coordinator generally keep sending Requests to Project Manager for Problems
rectification .Project Manager will assign the work to Project Leader and the Project Leader in
turn assigns the work based on the Module, who worked previously on it.

What are the Recent Modifications you did in the Project?


Where did you have programs to modify?
From Visual Source Safe.
How will you modify the programs when others are working on it simultaneously?

What are different types of Test types that are available?

What type of testing will you perform while designing and Developing Application?

Unit Testing is Generally Performed , after Developing the application.

What is Unit Testing ? How will you Perform it?

Unit Testing can be defined as Verification of Smallest unit in the Program.


This is performed by preparing Test Cases, Test Plans and Test Reports.
In Test Cases Expected Results are written, In Test Plans some Input values are feeded and Out
Puts will be noticed and In Test Reports all the Results are wrote and are verified.
What are the Performance Tips?

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

Вам также может понравиться