ASP.Net Interview Short Questions

ASP.Net Short Interview Questions

Differences between Server-side and Client-side code?
Server side code is executed at the server side on IIS in ASP.NET framework, while client side code is executed on the browser.

What’ is the sequence in which ASP.NET events are processed ?  1 Page_Init.
2 Page_Load.
3 Control events
4 Page_Unload event.
Page_init event only occurs when first time the page is started, but Page_Load occurs in subsequent request of the page.

In which event are the controls fully loaded ?
Page_load event guarantees that all controls are fully loaded. Controls are also accessed in Page_Init events but you will see that viewstate is not fully loaded during this event.

How can we identify that the Page is PostBack ? 

Page object has a “IsPostBack” property which can be checked to know that is the page posted back.

What is event bubbling ?

Server controls like Datagrid, DataList, Repeater can have other child controls inside them. Example DataGrid can have combo box inside datagrid. These child control do not raise there events by themselves, rather they pass the event to the container parent (which can be a datagrid, datalist, repeater), which passed to the page as “ItemCommand” event. As the child control send there events to parent this is termed as event bubbling.

How do we assign page specific attributes ?

Page attributes are specified using the @Page directive.

What is the use of @ Register directives ?

@Register directive informs the compiler of any custom server control added to the page.

What’s the use of SmartNavigation property ?

It’s a feature provided by ASP.NET to prevent flickering and redrawing when the page is posted back.

What type of code (server or client) is found in a Code-Behind class?

Server side code.

How many ways can we maintain the state of a page?

1. Client Side – Query string, hidden variables, viewstate, cookies
2. Server side – application , cache, context, session, database

What is AppSetting Section in “Web.Config” file ?

Web.config file defines configuration for a webproject. Using “AppSetting” section we can define user defined values. Example below defined is “ConnectionString” section which will be used through out the project for database connection.

Where is ViewState information stored ?

In HTML Hidden Fields
How many types of validation controls are provided by ASP.NET ?
There are six main types of validation controls :-RequiredFieldValidator It checks whether the control have any value. It’s used when you want the control should not be empty.

 RangeValidator It checks if the value in validated control is in that specific range. Example TxtMobileNo should be ten digit length.

CompareValidator It checks that the value in controls should match the value in other control. Example compare password with confirm password in registration form.

RegularExpressionValidator When we want the control value should match with a specific regular expression. We use it in Email and website address format check in registration form.

CustomValidator It is used to define UserDefined validation.

ValidationSummary It displays summary of all current validation errors at one place on web forms.

How can you enable automatic paging in DataGrid ?

Following are the points to be done in order to enable paging in Datagrid :-
- Set the “AllowPaging” to true.
-  In PageIndexChanged event set the current pageindex clicked.
What is the difference between “Web.config” and “Machine.Config”?
“Web.config” files apply settings to each web application, while “Machine.config” file apply settings to all ASP.NET applications.
What is a SESSION and APPLICATION object ? 
Session object store information between HTTP requests for a particular user, while application object are global across users.
Explain the differences between Server-side and Client-side code?
Server side code is executed at the server side on IIS in ASP.NET framework, while client side code is executed on the browser.
What is Difference between NameSpace and Assembly?
Following are the differences between namespace and assembly :
- Assembly is physical grouping of logical units. Namespace logically groups classes.
- Namespace can span multiple assembly.
What is the difference between Convert.toString and .toString() method ?
int i =0;
MessageBox.Show(i.ToString());
MessageBox.Show(Convert.ToString(i));
We can convert the integer “i” using “i.ToString()” or “Convert.ToString” so what’s the difference. The basic difference between them is “Convert” function handles NULLS while “i.ToString()” does not it will throw a NULL reference exception error. So as good coding practice using “convert” is always safe.

What is difference between abstract classes and interfaces?
-  Abstract classes can have concrete methods while interfaces have no methods implemented.
- Interfaces do not come in inheriting chain, while abstract classes come in inheritance.

What is a CLR?

Full form of CLR is Common Language Runtime and it forms the heart of the .NET framework. All Languages have runtime and its the responsibility of the runtime to take care of the code execution of the program.
Following are the responsibilities of CLR
- Garbage Collection
- Code Access Security
- Code Verification
What is a IL?
(IL)Intermediate Language is also known as MSIL (Microsoft Intermediate Language) or CIL (Common Intermediate Language). All .NET source code is compiled to IL. This IL is then converted to machine code at the point where the software is installed, or at run-time by a Just-In- Time (JIT) compiler.
What is a CTS?
In order that two language communicate smoothly CLR has CTS (Common Type System).Example in VB you have “Integer” and in C++ you have “long” these datatypes are not compatible so the interfacing between them is very complicated. In order to able that two different languages cancommunicate Microsoft introduced Common Type System. So “Integer” datatype in VB6 and “int” datatype in C++ will convert it to System.int32 which is datatype of CTS. CLS which is covered in the coming question is subset of CTS.
What is a CLS(Common Language Specification)?
This is a subset of the CTS which all .NET languages are expected to support. It was always a dream of Microsoft to unite all different languages in to one umbrella and CLS is one step towards that. Microsoft has defined CLS which are nothing but guidelines that language to follow so that it can communicate with other .NET languages in a seamless manner.
What is a Managed Code?
Managed code runs inside the environment of CLR i.e. .NET runtime. In short all IL are managed code. But if you are using some third party software example VB6 or VC++ component they are unmanaged code as .NET runtime (CLR) does not have control over the source code execution of the language.
What is a Assembly?
Assembly is unit of deployment like EXE or a DLL.
An assembly consists of one or more files (dlls, exe’s, html files etc.), and represents a group of resources, type definitions, and implementations of those types. An assembly may also contain references to other assemblies. These resources, types and references are described in a block of data called a manifest. The manifest is part of the assembly, thus making the assembly self-describing.
An assembly is completely self-describing.An assembly contains metadata information, which is used by the CLR for everything from type checking and security to actually invoking the components methods. As all information is in the assembly itself, it is independent of registry. This is the basic advantage as compared to COM where the version was stored in registry
What is NameSpace?
Namespace has two basic functionality :-
- NameSpace Logically group types, example System.Web.UI logically groups our UI related features.
- In Object Oriented world many times its possible that programmers will use the same class name.By qualifying NameSpace with classname this collision is able to be removed.
What is Manifest?
Assembly metadata is stored in Manifest. Manifest contains all the metadata needed to do the following things (See Figure Manifest View for more details):
- Version of assembly
- Security identity
- Scope of the assembly
- Resolve references to resources and classes.
- The assembly manifest can be stored in either a PE file (an .exe or .dll) with Microsoft intermediate language (MSIL) code or in a stand-alone PE file that contains only assembly manifest information.
Where is version information stored of an assembly ?
Version information is stored in assembly in manifest.
Is versioning applicable to private assemblies?
Versioning concept is only applicable to global assembly cache (GAC) as private assembly lie in their individual folders.
What is GAC ?
GAC (Global Assembly Cache) is used where shared .NET assembly reside. GAC is used in the following situations :-
- If the application has to be shared among several application.
- If the assembly has some special security requirements like only administrators can remove the assembly. If the assembly is private then a simple delete of assembly the assembly file will remove the assembly.
What is garbage collection?
Garbage collection is a CLR feature which automatically manages memory. Programmers forget to release the objects while coding ….. Laziness (Remember in VB6 where one of the good practices is to set object to nothing). CLR automatically releases objects when they are no longer in use and refernced. CLR runs on non-deterministic to see the unused objects and cleans them. One side effect of this non-deterministic feature is that we cannot assume an object is destroyed when it goes out of the scope of a function. Therefore, we should not put code into a class destructor to release resources.
Can we force garbage collector to run ?
System.GC.Collect() forces garbage collector to run. This is not recommended but can be used if situations arises.
What is reflection?
 All .NET assemblies have metadata information stored about the types defined in modules. This metadata information can be accessed by mechanism called as “Reflection”.System.
Reflection can be used to browse through the metadata information. Using reflection you can also dynamically invoke methods using System.Type.Invokemember. Below is sample source code if needed you can also get this code from CD provided, go to “Source code” folder in “Reflection Sample” folder.
What are different types of JIT ?
JIT compiler is a part of the runtime execution environment.
In Microsoft .NET there are three types of JIT compilers:
- Pre-JIT :- Pre-JIT compiles complete source code into native code in a single compilation cycle. This is done at the time of deployment of the application.
- Econo-JIT :- Econo-JIT compiles only those methods that are called at runtime. However, these compiled methods are removed when they are not required.
- Normal-JIT :- Normal-JIT compiles only those methods that are called at runtime. These methods are compiled the first time they are called, and then they are stored in cache. When the same methods are called again, the compiled code from cache is used for execution.
What are Value types and Reference types?
Value types directly contain their data which are either allocated on the stack or allocated in-line in a structure. Reference types store a reference to the value’s memory address, and are allocated on the heap. Reference types can be self-describing types, pointer types, or interface types. Variables that are value types each have their own copy of the data, and therefore operations on one variable do not affect other variables. Variables that are reference types can refer to the same object; therefore, operations on one variable can affect the same object referred to by another variable. All types derive from the System.Object base type.
What is Boxing and Unboxing ?
Boxing permits any value type to be implicitly converted to type object or to any interface type implemented by value type. Boxing is a process in which object instances are created and copy values in to that instance. Unboxing is vice versa of boxing operation where the value is copied from the instance in to appropriate storage location. Below is sample code of boxing and unboxing where integer data type is converted in to object and then vice versa.
Dim x As Integer
Dim y As Object
x = 10
‘ boxing process
y = x
‘ unboxing process
x = y
What is the difference between Authentication and authorization?
Authentication is verifying the identity of a user and authorization is process where we check does this identity have access rights to the system. In short we can say the following authentication is the process of obtaining some sort of credentials from the users and using those credentials to verify the user’s identity. Authorization is the process of allowing an authenticated user access to resources. Authentication always proceed to Authorization; even if your application lets anonymous users connect and use the application, it still authenticates them as being anonymous.

One Response to ASP.Net Interview Short Questions

  1. Hiren patel says:

    Good Website

Leave a Reply

Your email address will not be published. Required fields are marked *

3 + 8 =


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">