Congratulations to all the winners of April 2013, they have won INR 3400 cash and INR 20147 worth prizes !
DotNetFunda.Com Logo
Twitter TwitterLinkedIn
YouTubeGoogle
 Online : 12311 |  Welcome, Guest!   Register  Login
 Home > Interview Questions > ASP.NET Interview Questions

Now you don't need go anywhere to get the best interview questions on Microsoft technology. We are trying to gather all real interview questions asked from MNCs and put them here. You can also assist us in doing so by submitting .net interview questions. These questions are generally different from certification questions however it may help you in that too.



Page copy protected against web site content infringement by Copyscape
A throw statement is used to generate exception explicitly.
This throw statement is generally used in recording error in event log or sending an Email notification about the error.
Avoid using throw statement as it degrades the speed.

Example:

try

{
//Code that might generate error
}
catch(Exception error)
{
//Code that handle errors occurred in try block

throw; //Re throw of exception to add exception details in event log or sending email
}

//Code that handle errors occurred in try block
}
finally
{
//Code to dispose all allocated resources
}

Format2

try
{
//Code that might generate error
}
finally
{
//Code to dispose all allocated resources
}

What is Exception?
An Exception is an unexpected error or problem.
What is Exception Handling?
It is a method to handle the error and solution to recover from it which makes the program to work smoothly.

What is try Block?
The try block consists of the code that might generate an error.
This try block must be associated with one or more catch blocks or by finally block.
The try block may not have a catch block associated with it every time but in this case,it must have a finally block associated with it instead of catch block.

Example:

Format1


try
{
//Code that might generate error
}
catch(Exception error)
{
}

Format2

try
{
//Code that might generate error
}
catch(ExceptionA error)
{
}
catch(ExceptionB error)
{
}

Format3

try
{
//Code that might generate error
}
finally
{
}


What is catch Block?
catch block is used to recover from error generated in the try block.
In case of multiple catch blocks,only the first matching catch block is excecuted.
you need to arrange the multiple catch blocks from specific exception type to more generic type.
If none of the matching catch blocks are able to handle the exception, the default behaviour of web page is to terminate the processing of the web page.

Example:

Format1


try
{
//Code that might generate error
}
catch(Exception error)
{
//Code that handle errors occurred in try block
}

Format2:

try
{
//Code that might generate error
}
catch(DivideByZeroException error)
{
//Code that handle errors occurred in try block
//It is the most specific error we are trying to catch
}
catch(Exception error)
{
//Code that handle errors occurred in try block
//It is not specific error we are catching
}
catch
{
//Code that handle errors occurred in try block
//It is the least specific error in hierarchy
}


What is finally Block?
The finally block contains the code that executes,whether an exception occurs or not.
The finally block is used to write code to close files,database connections,etc.
Only one finally block is associated with each try block.
finally block must appear only after the catch block.
If there are any control statements such as goto,break or continue in either try or catch block,the transfer happens only after the code in the finally block is excecuted.
If the control statements are used in finally block,there occurs a compile time error.

Example:

Format1


try
{
//Code that might generate error
}
catch(Exception error)
{
//Code that handle errors occurred in try block
}
finally
{
//Code to dispose all allocated resources
}

Format2

try
{
//Code that might generate error
}
finally
{
//Code to dispose all allocated resources
}

NOTE: This is objective type question, Please click question title for correct answer.

DLL Hell:

DLL Hell refers to the set of problems while sharing multiple applications under a single common component like Dynamic Link Library(DLL) or a Component Object Model(COM) class.
Simply, it is the problem which occurs while registering the DLL components with a common name.
DOT Net has removed this problem by introducing the concept of versioning.

Versioning:

Versioning is a process where, every shared application creates its own version number.

For Example, Let us assume that the version number of the first registered DLL takes as V1.0.
And Now, you want to overwrite the first registered DLL by installing another DLL with same name.
Then the version number of the second registered DLL would be taken as V2.0.

By this way we can avoid the conflicts of DLL registration and can overwrite the registered DLLs successfully.

Abstract Class:

a) An abstract class is a special kind of class that cannot be instantiated.
b) It allows the other classes to inherit from it but cannot be instantiated.
c) It is used to carry the same hierarchy or standards for all the subclasses.


Interface:

a) An interface is not a class,but it is an entity and has no implementation.
b) It has only the definition of the methods without the body.


Differences:

1) A class may inherit several interfaces, but inherit only one abstract class.
2) An abstract class cn provide complete code, but interface provides just the signature.
3) An abstract class can contain access modifiers for the subs, functions, properties, but an interface cannot.
4) An abstract class defines the core identity of a class, but interfaces are used to define the peripheral abilities of a class.
5) An abstract class is fast whereas the interfaces requires more time to find the actual method in the corresponding classes.
6) If we add a new method to an abstract class, there we can provide the default implementation and therefore all the existing code might work properly whereas in interface, we have to track down all the implementations of the interface and define implementation for the new method.
7) In Interface, we cannot define the fields whereas in an Abstract class, we can define the fields and constants.

Say our PDF files are on the disk then we should let the IIS to handle it. The reason being the caching done through IIS is much faster than ASP.NET cache.

In IIS the caching done through IIS static file handler.

At times we need to make sure that all the cache which was used must be cleared.

This can be done in many ways here is one of the way using the dictionary object

foreach(DictionaryEntry objClearItem in Cache)   

{
//Response.Write (objClearItem .Key.ToString ());
Cache.Remove(objClearItem .Key.ToString () ) ;
}

Yes we can access cache from a compiled class. Here is the code to it.

MyVariable=System.Web.HttpContext.Current.Cache("<CacheName>");  

</CacheName>

AutoPostBack is a feature available that is available on few controls.
The main purpose of this feature is that, if there is any change done on the client side, then it should be handled on the server side.

Usage:

<asp:TextBox AutoPostBack="TRUE|FALSE" runat="server"/> 


Example:

<form runat="server">

<asp:TextBox id="txtBox1" runat="server" AutoPostBack="TRUE" />
</form>

Both are objects of ASP.Net and are used to transfer user from one page to another page.

Syntax:

Response.Redirect("Default.aspx");


Server.Transfer("Default.aspx");


Server.Transfer() can directly access the values, controls and properties of the previous page whereas you cannot do with Response.Redirect().

Authentication:

Authentication is the process of verifying the credentials such as username and password of the user and then allows that user to access the server.
This process can be done in many ways like :

Password based authentication

Device based authentication

Biometric authentication

For Example, if you use

Windows based Authentication and are browsing an ASP.NET page from server -- ASP.NET/IIS would automatically use NTLM to authenticate you as user1.

Forms based Authentication, then you would use an html based forms page to enter username/password -- which would then check a database and authenticate you against the username/password in the database.


Authorization:

Authorization is a process of verifying whether the user has got the permission to do the operation that he is requesting.

Both function and perform similarly, but still differ in following ways.

Web application:

a) We can't include c# and vb page in single web application.
b) We can set up dependencies between multiple projects.
c) Can not edit individual files after deployment without recompiling.
d) Right choice for enterprise environments where multiple developers work unitedly for creating,testing and deployment.


Web site:

a) Can mix vb and c# page in single website.
b) Can not establish dependencies.
c) Edit individual files after deployment.
d) Right choice when one developer will responsible for creating and managing entire website.

The default mapping logic used by ASP.NET MVC is as follows :-

/[Controller]/[ActionName]/[Parameters]


For example,
controller = "Home", action = "Index", id = UrlParameter



Thanks and Regards
Akiii

NOTE: This is objective type question, Please click question title for correct answer.

caching is generally used to catch frequently accessed data.
While using caching, you have to consider some of the parameters like parameter, time, etc.

Types of Caching:

1)Page Level Caching (called Output Caching) - Used to fetch page level data.

2)Page Fragment Caching (called Partial-Page Output Caching) - Used to catch the information of a structure level.

3)Programmatic or Data Caching (called Application Caching) - Used to fetch tha information of an Application.

Found this useful, bookmark this page link to the blog or social networking websites. Page copy protected against web site content infringement by Copyscape
Navigate to Page: 1 | ... | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | ... | 71 |

 More Exclusive ASP.NET Interview Questions and Answers here


Found interesting? Add this to:


About Us | Contact Us | The Team | Advertise | Software Development | Write for us | Testimonials | Privacy Policy | Terms of Use | Link Exchange | Members | Go Top
General Notice: If you find plagiarised (copied) contents on this page, please let us know the original source along with your correct email id (to communicate) for further action.
Copyright © DotNetFunda.Com. All Rights Reserved. Copying or mimicking the site design and layout is prohibited. Logos, company names used here if any are only for reference purposes and they may be respective owner's right or trademarks. | 5/19/2013 7:31:19 PM