ASP.NET Interview Q&A


1.       What is ASP.NET?
ASP.NET is a server side scripting technology that enables scripts (embedded in web pages) to be executed by an Internet server. ASP.NET provides increased performance by running compiled code.
------------------------------------------------------------------------------------------------------------------------------------------
2.       What is the difference between Classic ASP and ASP.Net? 
ASP is Interpreted language based on scripting languages like Jscript or VBScript.
  • ASP has Mixed HTML and coding logic.
  • Limited development and debugging tools available.
  • Limited OOPS support.
  • Limited session and application state management.
ASP.Net is supported by compiler and has compiled language support.
  • Separate code and design logic possible.
  • Variety of compilers and tools available including the Visual studio.Net.
  • Completely Object Oriented.
  • Complete session and application state management.
Full XML Support for easy data exchange.
------------------------------------------------------------------------------------------------------------------------------------------
3.       What is Difference between Namespace and Assembly?
Namespace is a logical design-time naming convenience, whereas an assembly establishes the name scope for types at run time.
------------------------------------------------------------------------------------------------------------------------------------------
4.       What is the difference between early binding and late binding?
Calling a non-virtual method, decided at a compile time is known as early binding. Calling a virtual method (Pure Polymorphism), decided at a runtime is known as late binding.
------------------------------------------------------------------------------------------------------------------------------------------
5.       What is the difference between ASP Session State and ASP.Net Session State?

ASP session state relies on cookies, Serialize all requests from a client, does not survive process shutdown, cannot maintained across machines in a Web farm.
------------------------------------------------------------------------------------------------------------------------------------------
6.       What is the difference between ASP Session and ASP.NET Session?
Asp.net session supports cookie less session & it can span across multiple servers.
------------------------------------------------------------------------------------------------------------------------------------------
7.        What is Difference between Namespace and Assembly?
Namespace is a collection of different classes. Whereas an assembly is the basic building blocks of the .net framework.
------------------------------------------------------------------------------------------------------------------------------------------
8.       What’ is the sequence in which ASP.NET events are processed?
Following is the sequence in which the events occur:-
• Page_Init.
• Page Load.
• Control events
• 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.
------------------------------------------------------------------------------------------------------------------------------------------
9.       Explain “AutoPostBack”?
If we want the control to automatically post back in case of any event, we will need to check this attribute as true. Example on a Combo Box change we need to send the event immediately to the server side then set the “AutoPostBack” attribute to true.
------------------------------------------------------------------------------------------------------------------------------------------
10.   How can we identify that the Page is Post Back?
Page object has an "IsPostBack" property, which can be checked to know that is the page posted back.
------------------------------------------------------------------------------------------------------------------------------------------
11.   What is the difference between early binding and late binding?
Calling a non-virtual method, decided at a compile time is known as early binding. Calling a virtual method (Pure Polymorphism), decided at a runtime is known as late binding.
------------------------------------------------------------------------------------------------------------------------------------------
12.   How can you display all validation messages in one control?
The Validation Summary control displays all validation messages in one control.
------------------------------------------------------------------------------------------------------------------------------------------
13.   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.
------------------------------------------------------------------------------------------------------------------------------------------
14.   What is the difference between Server.Transfer and response.Redirect?
The Server.Transfer () method stops the current page from executing, and runs the content on the specified page, when the execution is complete the control is passed back to the calling page.
While the Response.Redirect () method transfers the control on the specified page and the control is never passed back to calling page after execution.
------------------------------------------------------------------------------------------------------------------------------------------
15.   What is a PostBack?
The process in which a Web page sends data back to the same page on the server.
------------------------------------------------------------------------------------------------------------------------------------------
16.   What namespace does the Web page belong in the .NET Framework class hierarchy?
System.Web.UI.Page
------------------------------------------------------------------------------------------------------------------------------------------
17.   What is a bubbled event?
When you have a complex control, like DataGrid, writing an event processing routine for each object (cell, button, row, etc.) is quite tedious. The controls can bubble up their event handlers, allowing the main DataGrid event handler to take care of its constituents.
------------------------------------------------------------------------------------------------------------------------------------------
18.   What is the differences between Server-side and Client-side code?
Server-side code executes on the server.
Client-side code executes in the client’s browser.
------------------------------------------------------------------------------------------------------------------------------------------
19.   What is the difference between static or dynamic assemblies?
Assemblies can be static or dynamic.
Static assemblies can include .NET Framework types (interfaces and classes), as well as resources for the assembly (bitmaps, JPEG files, resource files, and so on). Static assemblies are stored on disk in portable executable (PE) files.
Dynamic assemblies, which are run directly from memory and are not saved to disk before execution. You can save dynamic assemblies to disk after they have executed.
------------------------------------------------------------------------------------------------------------------------------------------
20.   What are the difference between Structure and Class?
Structures are value type and Classes are reference type
Structures cannot have constructor or destructors.
Classes can have both constructor and destructors.
Structures do not support Inheritance, while Classes support Inheritance.
------------------------------------------------------------------------------------------------------------------------------------------
21.   What is the differences between dataset.clone and dataset.copy?
Dataset.clone copies just the structure of dataset (including all the datatables, schemas, relations and constraints.); however it doesn’t copy the data.
Dataset.copy, copies both the dataset structure and the data.
------------------------------------------------------------------------------------------------------------------------------------------
22.   What is the difference between Custom Control and User Control?
Custom Controls are compiled code (Dlls), easier to use, difficult to create, and can be placed in toolbox. Drag and Drop controls. Attributes can be set visually at design time. Can be used by Multiple Applications (If Shared Dlls), Even if Private can copy to bin directory of web application add reference and use. Normally designed to provide common functionality independent of consuming Application.
User Controls are similar to those of ASP include files, easy to create, cannot be placed in the toolbox and dragged - dropped from it. A User Control is shared among the single application files.
------------------------------------------------------------------------------------------------------------------------------------------
23.   What is the difference between ASP Session State and ASP.Net Session State?
ASP session state relies on cookies, Serialize all requests from a client, does not survive process shutdown, cannot maintained across machines in a Web farm.
------------------------------------------------------------------------------------------------------------------------------------------
24.   What is ViewState?
ViewState is a .Net mechanism to store the posted data among post backs. ViewState allows the state of objects to be stored in a hidden field on the page, saved on client side and transported back to server whenever required.
------------------------------------------------------------------------------------------------------------------------------------------
25.   What is Authentication and Authorization?
Authentication is the process of identifying users. Authentication is identifying/validating the user against the credentials (username and password) and Authorization performs after authentication.
Authorization is the process of granting access to those users based on identity. Authorization allowing access of specific resource to user.
------------------------------------------------------------------------------------------------------------------------------------------
26.   What are the types of Authentication?        
There are 3 types of Authentication. Windows, Forms and Passport Authentication.
Windows authentication uses the security features integrated into the Windows NT and Windows XP operating systems to authenticate and authorize Web application users.
Forms authentication allows you to create your own list/database of users and validate the identity of those users when they visit your Web site.
Passport authentication uses the Microsoft centralized authentication provider to identify users. Passport provides a way to for users to use a single identity across multiple Web applications. To use Passport authentication in your Web application, you must install the Passport SDK.
------------------------------------------------------------------------------------------------------------------------------------------
27.   What are different types of directives in .NET?

    @Page
    @Control
    @Import
    @Implements
    @Register
    @Assembly
    @OutputCache
    @Reference
------------------------------------------------------------------------------------------------------------------------------------------
28.   What is cookies?
Cookies are small pieces of text, stored on the client’s computer to be used only by the website setting the cookies. This allows webapplications to save information for the user, and then re-use it on each page if needed
------------------------------------------------------------------------------------------------------------------------------------------
29.   How many languages .NET is supporting now?
When .NET was introduced it came with several languages. VB.NET, C#, COBOL and Perl, etc. The site DotNetLanguages.Net says 44 languages are supported.
------------------------------------------------------------------------------------------------------------------------------------------
30.   What is boxing and unboxing?
Implicit conversion of value type to reference type of a variable is known as BOXING, for example integer to object type conversion.
Conversion of reference type variable back to value type is called as UnBoxing.
------------------------------------------------------------------------------------------------------------------------------------------
31.   What is garbage collection?
Garbage collection is a system whereby a run-time component takes responsibility for managing the lifetime of objects and the heap memory that they occupy.
------------------------------------------------------------------------------------------------------------------------------------------
32.   What is serialization?
Serialization is the process of converting an object into a stream of bytes.
Deserialization is the opposite process of creating an object from a stream of bytes. Serialization / Deserialization is mostly used to transport objects.
------------------------------------------------------------------------------------------------------------------------------------------
33.   What is the differnce between Managed code and unmanaged code?
Managed Code: Code that runs under a "contract of cooperation" with the common language runtime. Managed code must supply the metadata necessary for the runtimeto provide services such as memory management, cross-language integration, code access security, and automatic lifetime control of objects. All code based on Microsoft intermediate language (MSIL) executes as managed code.
Un-Managed Code:Code that is created without regard for the conventions and requirements of the common language runtime. Unmanaged code executes in the common language runtime environment with minimal services (for example, no garbage collection, limited debugging, and so on).
------------------------------------------------------------------------------------------------------------------------------------------
34.   What is difference between constants, readonly and, static?
               
Constants: The value can’t be changed.
Read-only: The value will be initialized only once from the constructor of the class.
Static: Value can be initialized once.
------------------------------------------------------------------------------------------------------------------------------------------
35.   What is the difference between ASP Session and ASP.NET Session?
Asp.net session supports cookie less session & it can span across multiple servers.
------------------------------------------------------------------------------------------------------------------------------------------
36.   What’s the use of “GLOBAL.ASAX” file?
It allows to executing ASP.NET application level events and setting application-level variables.
------------------------------------------------------------------------------------------------------------------------------------------
37.   What is a SESSION and APPLICATION object?
Session object store information between HTTP requests for a particular user.
Session variables are used to store user specific information where as in application variables we can’t store user specific information.
while application object are global across users.
------------------------------------------------------------------------------------------------------------------------------------------
38.   What is a DataSet?
A DataSet is an in memory representation of data loaded from any data source.
------------------------------------------------------------------------------------------------------------------------------------------
39.   What is a DataTable?
A DataTable is a class in .NET Framework and in simple words a DataTable object represents a table from a database.
------------------------------------------------------------------------------------------------------------------------------------------
40.   How many namespaces are in .NET version 1.1?
124
------------------------------------------------------------------------------------------------------------------------------------------
41.   What is the main difference between Asp.net and Vb.net?
Asp.net is a web technology used for designing webforms and Vb.net is a programming language
ASP.NET is a powerful technology for writing dynamic web pages.
ASP.NET is a way of creating dynamic web pages while making use of the innovations present in .NET.
VB.NET is a language.But ASP.NET is the Environment where we can create websites or webpages.
------------------------------------------------------------------------------------------------------------------------------------------
42.   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.
------------------------------------------------------------------------------------------------------------------------------------------
43.   What is the base class of .net?
System.object
------------------------------------------------------------------------------------------------------------------------------------------
44.   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.
------------------------------------------------------------------------------------------------------------------------------------------
45.   What is the base class of Asp.net?
system.Web.UI
------------------------------------------------------------------------------------------------------------------------------------------
46.   What are page directives?
The first line of an ASP.NET page is the page directive; you will find it on all ASP.NET pages. These directives are instructions for the page. It begins with the @Page directive and continues with the various attributes available to this directive.
It’s unreasonable to expect a candidate to know all of these attributes, but a few popular ones include the following.
  • AutoEventWireup: Indicates whether page events are autowired.
  • CodeBehind: The name of the compiled class associated with the page.
  • Debug: Indicates whether the page is compiled in debug mode (includes debug symbols).
  • EnableTheming: Indicates whether themes are used on the page.
  • EnableViewState: Indicates whether view state is maintained across pages.
  • ErrorPage: Specifies a target URL to be used when unhandled exceptions occur.
  • Language: Indicates the language used when compiling inline code on the page.
  • Trace: Signals whether tracing is enabled on the page.
------------------------------------------------------------------------------------------------------------------------------------------
47.   What is a master page?
A master page is a template for one or more Web Forms. The master page defines how the page will be laid out when presented to the user, with placeholders for content. The MasterPageFile Page Directive in a content page’s header is one way to assign a master page. The content pages rely solely on content and leave layout to the master page. ASP.NET merges the content with the master page layout when the content page is requested by a user.
------------------------------------------------------------------------------------------------------------------------------------------
48.   What is the code behind feature of ASP.NET?
The code behind feature divides ASP.NET page files into two files where one defines the user interface (.aspx), while the other contains all of the logic or code (.aspx.cs for C# and .aspx.vb for VB.NET). These two files are glued together with page directives like the following line, which ties the page to the specific code behind class.
<%@ Page language="c#" Codebehind="UICode.cs" Inherits="Library.UICode" %>
------------------------------------------------------------------------------------------------------------------------------------------
49.   What are ASHX files?
ASP.NET Web handler files have an .ashx file extension. Web handlers work just like .aspx files except you don’t have to deal with the browser interface, thus no worrying about presentation. Web handlers are generally used to generate content dynamically like returning XML or an image. Web handlers use the IHttpHandler interface with the ProcessRequest() method invoked when the handler is requested. Web handlers are simpler than pages (fewer events and wiring), so they are ideal for performance-critical applications.
------------------------------------------------------------------------------------------------------------------------------------------
50.   What is View State?
Basically, View State is how ASP.NET Web pages persists data across requests. It handles data that must be preserved between postbacks, and you can use it to store page-specific data. By default, View State is enabled on a page and its controls. This can be a problem as the amount of data and controls on a page increases resulting in more data for ASP.NET to maintain. This is accomplished via the hidden __VIEWSTATE field on a form (look at the page source in a browser), so more data in this field means a slower load time and slower overall processing, as it has to be posted to the server each time. You can limit the size of the data in View State by disabling controls that do not need to be persisted via the EnableViewState property. View State can be encrypted to address security concerns.
------------------------------------------------------------------------------------------------------------------------------------------









No comments:

Post a Comment