jQuery Show Popup on Page Load

10 Nov 2013

Most Frequently Asked Interview Questions - Asp.Net 3 + Years

What is asp.net life cycle ? 


The properties like IsPostBack have been set at this time.

This event will be used when we want to:

  1. Set master page dynamically.
  2. Set theme dynamically.
  3. Read or set profile property values.
  4. This event is also preferred if want to create any dynamic controls.

  1. Raised after all the controls have been initialized with their default values and any skin settings have been applied.
  2. Fired for individual controls first and then for page.

  1. Fires only if IsPostBack is true.
  2. Values stored in HiddenField with id as _ViewState decoded and stored into corresponding controls.

Some controls like:

  1. Fires only if IsPostBack is true.
  2. Some controls like Textbox are implemented from IPostBackDataHandler and this fires only for such controls.
  3. In this event page processes postback data included in the request object pass it to the respective controls.

  • Used only if want to inject logic before actual page load starts.

  • Used normally to perform tasks which are common to all requests, such as setting up a database query.
Control events

  1. This event is fired when IsPostBack is true.
  2. Use these events to handle specific control events, such as a Button control's Click event or a TextBox control's TextChanged event.
PreRenderRaised after the page object has created all the controls that are required for rendering which includes child controls and composite controls.

  1. Use the event to make final changes to the contents of the page or its controls before the values are stored into the viewstate and the rendering stage begins.
  2. Mainly used when we want to inject custom JavaScript logic.

  • All the control values that support viewstate are encoded and stored into the viewstate.
RenderGenerates output (HTML) to be rendered at the client side.

  • We can add custom HTML to the output if we want here.

  1. Fired for individual controls first and then for page.
   2. Used to perform cleanup work like closing open files and database connections.  

 Difference between ASP.NET HttpHandler and HttpModule

What are http handlers and modules. And in which condition which one is suitable. For that first we need to understand when user request application resource to web server, what happened? The user requests for a resource on web server. The web server examines the file name extension of the requested file, and determines which ISAPI extension should handle the request. Then the request is passed to the appropriate ISAPI extension. For example when an .aspx page is requested it is passed to ASP.Net page handler. Then Application domain is created and after that different ASP.Net objects like Httpcontext, HttpRequest, HttpResponse are created. Then instance of HttpApplication is created and also instance of any configured modules. One can register different events of HttpApplication class like BeginRequest, AuthenticateRequest, AuthorizeRequest, ProcessRequest etc.

HTTP Handler

HTTP Handler is the process which runs in response to a HTTP request. So whenever user requests a file it is processed by the handler based on the extension. So, custom http handlers are created when you need to special handling based on the file name extension. Let's consider an example to create RSS for a site. So, create a handler that generates RSS-formatted XML. Now bind the .rss extension to the custom handler.

HTTP Modules

HTTP Modules are plugged into the life cycle of a request. So when a request is processed it is passed through all the modules in the pipeline of the request. So generally http modules are used for:
Security: For authenticating a request before the request is handled.
Statistics and Logging: Since modules are called for every request they can be used for gathering statistics and for logging information.
Custom header:  Since response can be modified, one can add custom header information to the response.

More clear difference between HttpHandler and HttpModule for experience guys

Meaning:- An ASP.NET HTTP handler is the process (frequently referred to as the "endpoint") that runs in response to a request made to an ASP.NET Web application. The most common handler is an ASP.NET page handler that processes .aspx files. When users request an .aspx file, the request is processed by the page through the page handler. We can create our own HTTP handlers that render custom output to the browser.In order to create a Custom HTTP Handler,we need to Implement IHttpHandler interface(synchronous handler) or
Implement IHttpAsyncHandler(asynchronous handler).

2.When to use HTTP handlers:

RSS feeds: To create an RSS feed for a Web site, we can create a handler that emits RSS-formatted XML. We can then bind a file name extension such as .rss to the custom handler. When users send a request to your site that ends in .rss, ASP.NET calls our handler to process the request.
Image server: If we want a Web application to serve images in a variety of sizes, we can write a custom handler to resize images and then send them to the user as the handler’s response.

3.How to develop an ASP.NET handler:

All we need is implementing IHttpHandler interface

public class MyHandler :IHttpHandler
public bool IsReusable
get { return false; }

public void ProcessRequest(HttpContext context)


4.Number of HTTP handler called:

During the processing of an http request, only one HTTP handler will be called.

5.Processing Sequence:

In the asp.net request pipe line ,http handler comes after http Module and it is the end point objects in ASP.NET pipeline.

6.What it does actually?

HTTP Handler actually processes the request and produces the response

7.HTTP Handler implement following Methods and Properties:

Process Request: This method is called when processing asp.net requests. Here you can perform all the things related to processing request.
IsReusable: This property is to determine whether same instance of HTTP Handler can be used to fulfill another request of same type.

8. Configuring HTTP handler in web.config :
We can use <httpHandlers> and <add> nodes for adding HTTP
handlers to our Web applications. In fact the handlers are
listed with <add> nodes in between <httpHandlers> and
</httpHandlers> nodes.
Ex: <httpHandlers>
<add verb="supported http verbs" path="path"
type="namespace.classname, assemblyname" />
(In this verb=GET/POST/HEAD path=path for
incoming HTTP requests type=…)

Meaning:- An HTTP module is an assembly that is called on every request that is made to our application. HTTP modules are called as part of the ASP.NET request pipeline and have access to life-cycle events throughout the request. HTTP modules examine incoming and outgoing requests and take action based on the request.

2.When to use HTTP modules:

Security: Because we can examine incoming requests, an HTTP module can perform custom authentication or other security checks before the requested page, XML Web service, or handler is called. In Internet Information Services (IIS) 7.0 running in Integrated mode, we can extend forms authentication to all content types in an application.
Statistics and logging: Because HTTP modules are called on every request, we can gather request statistics and log information in a centralized module, instead of in individual pages.
Custom headers or footers: Because we can modify the outgoing response, we can insert content such as custom header information into every page or XML Web service response.

3.How to develop a Http Module:

All we need is implementing System.Web.IHttpModule interface.

public class MyHttpModule : IHttpModule
public void Dispose()


public void Init(HttpApplication context)
//here we have to define handler for events such as BeginRequest ,PreRequestHandlerExecute ,EndRequest,AuthorizeRequest and ....


// you need to define event handlers here

4.Number of HTTP module called:

Whereas more than one HTTP modules may be called. 

5. Processing Sequence:

In the asp.net request pipe line, http Module comes first.

6.What it does actually?

HTTP module can work on request before and on the response after HTTP Handler 

7.Http Module implements following Methods and Properties:

InIt: This method is used for implementing events of HTTP Modules in HTTPApplication object.
Dispose: This method is used perform cleanup before Garbage Collector destroy everything.

8.Configuring HTTP Modules in web.config:
Ex: <system.web>
<add name="MyModule"
type="MyModule.SyncModule, MyModule" />

Describe the role of inetinfo.exe, aspnet_isapi.dll and aspnet_wp.exe in the page loading process. 

inetinfo.exe is the Microsoft IIS server running, handling ASP.NET requests among other things. When an ASP.NET request is received (usually a file with .aspx extension),the ISAPI filter aspnet_isapi.dll takes care of it by passing the request to the actual worker process aspnet_wp.exe.  
What’s the difference between Response.Write() and Response.Output.Write()? 

The latter one allows you to write formatted output.  
What methods are fired during the page load? 

Init() - when the page is instantiated, 
Load() - when the page is loaded into server memory, 
PreRender() - the brief moment before the page is displayed to the user as HTML, 
Unload() - when page finishes loading.  
Where does the Web page belong in the .NET Framework class hierarchy? 
Where do you store the information about the user’s locale? 
What’s the difference between Codebehind="MyCode.aspx.cs" and Src="MyCode.aspx.cs"?
  CodeBehind is relevant to Visual Studio.NET only. 

What’s 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. 

 Suppose you want a certain ASP.NET function executed on MouseOver over a certain button. Where do you add an event handler? 
It’s the Attributes property, the Add function inside that property. So btnSubmit.Attributes.Add("onMouseOver","someClientCode();") 

What data type does the RangeValidator control support? 
Integer, String and Date.

Explain the differences between Server-side and Client-side code? 
Server-side code runs on the server. Client-side code runs in the clients’ browser.

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

Should validation (did the user enter a real date) occur server-side or client-side? Why? 
Client-side. This reduces an additional request to the server to validate the users input.

What does the "EnableViewState" property do? Why would I want it on or off? 
It enables the viewstate on the page. It allows the page to save the users input on a form.

What is the difference between Server.Transfer and Response.Redirect? Why would I choose one over the other? 
Server.Transfer is used to post a form to another page. Response.Redirect is used to redirect the user to another page or site.

 Can you explain the difference between an ADO.NET Dataset and an ADO Recordset? 

• A DataSet can represent an entire relational database in memory, complete with tables, relations, and views. 
• A DataSet is designed to work without any continuing onnection to the original data source. 
• Data in a DataSet is bulk-loaded, rather than being loaded on demand. 
• There's no concept of cursor types in a DataSet. 
• DataSets have no current record pointer You can use For Each loops to move through the data. 
• You can store many edits in a DataSet, and write them to the original data source in a single operation. 
• Though the DataSet is universal, other objects in ADO.NET come in different versions for different data sources. 

Can you give an example of what might be best suited to place in the Application_Start and Session_Start subroutines? 
This is where you can set the specific variables for the Application and Session objects.

 If I’m developing an application that must accommodate multiple security levels though secure login and my ASP.NET web application is spanned across three web-servers (using round-robin load balancing) what would be the best approach to maintain login-in state for the users? 
Maintain the login state security through a database.

Can you explain what inheritance is and an example of when you might use it? 
When you want to inherit (use the functionality of) another class. Base Class Employee. A Manager class could be derived from the Employee base class.

Whats an assembly? 
Assemblies are the building blocks of the .NET framework. Overview of assemblies from MSDN

Describe the difference between inline and code behind. 

Inline code written along side the html in a page. Code-behind is code written in a separate file and referenced by the .aspx page.

Explain what a diffgram is, and a good use for one? The DiffGram is one of the two XML formats that you can use to render DataSet object contents to XML. For reading database data to an XML file to be sent to a Web Service.

Whats MSIL, and why should my developers need an appreciation of it if at all? 
MSIL is the Microsoft Intermediate Language. All .NET compatible languages will get converted to MSIL.

Which method do you invoke on the DataAdapter control to load your generated dataset with data? 
The .Fill() method

Can you edit data in the Repeater control? No, it just reads the information from its data source

Which template must you provide, in order to display data in a Repeater control? 

How can you provide an alternating color scheme in a Repeater control? 
Use the AlternatingItemTemplate

What property must you set, and what method must you call in your code, in order to bind the data from some data source to the Repeater control? 
You must set the DataSource property and call the DataBind method.

What base class do all Web Forms inherit from? The Page class.

Name two properties common in every validation control? ControlToValidate property and Text property.

What tags do you need to add within the asp:datagrid tags to bind columns manually? Set AutoGenerateColumns Property to false on the datagrid tag

What tag do you use to add a hyperlink column to the DataGrid? <asp:HyperLinkColumn>

What is the transport protocol you use to call a Web service? SOAP is the preferred protocol. 

True or False: A Web service can only be written in .NET? False

What does WSDL stand for? (Web Services Description Language)

Which property on a Combo Box do you set with a column name, prior to setting the DataSource, to display data in the combo box? DataTextField property 

Which control would you use if you needed to make sure the values in two different controls matched? CompareValidator Control

True or False: To test a Web service you must create a windows application or Web application to consume this service?False, the webservice comes with a test page and it provides HTTP-GET method to test.

How many classes can a single .NET DLL contain? It can contain many classes.
optimization technique description
 Avoid unnecessary use of view state which lowers the performance.
 Avoid the round trips to server.
 Use connection pooling.
 Use stored procedures.
What serialization?
Serialization is a process of conversion an objects into stream of bytes so that they can transfer through the channels. 

26) About a class access specifiers and method access specifiers Public : available throughout application.
 Private : available for class and its inherited class.
 Protected : restricted to that class only.
 Internal : available throughout that assembly. 

What are the different types of caching?
Caching is a technique widely used in computing to increase performance by keeping frequently accessed or expensive data in memory. In context of web application, caching is used to retain the pages or data across HTTP requests and reuse them without the expense of recreating them.ASP.NET has 3 kinds of caching strategiesOutput CachingFragment CachingData

CachingOutput Caching:
 Caches the dynamic output generated by a request. Some times it is useful to cache the output of a website even for a minute, which will result in a better performance. For caching the whole page the page should have OutputCache directive.
<%@ OutputCache Duration="60" VaryByParam="state" %>

Fragment Caching:
 Caches the portion of the page generated by the request. Some times it is not practical to cache the entire page, in such cases we can cache a portion of page<%@ OutputCache Duration="120" VaryByParam="CategoryID;SelectedID"%>

Data Caching: Caches the objects programmatically. For data caching asp.net provides a cache object for eg: cache["States"] = dsStates; 

What are different types of directives in .NET?
@Page: Defines page-specific attributes used by the ASP.NET page parser and compiler. Can be included only in .aspx files <%@ Page AspCompat="TRUE" language="C#" %>

@Control:Defines control-specific attributes used by the ASP.NET page parser and compiler. Can be included only in .ascx files. <%@ Control Language="VB" EnableViewState="false" %>

@Import: Explicitly imports a namespace into a page or user control. The Import directive cannot have more than one namespace attribute. To import multiple namespaces, use multiple @Import directives. <% @ Import Namespace="System.web" %>

 Indicates that the current page or user control implements the specified .NET framework interface.<%@ Implements Interface="System.Web.UI.IPostBackEventHandler" %>

 Associates aliases with namespaces and class names for concise notation in custom server control syntax.<%@ Register Tagprefix="Acme" Tagname="AdRotator" Src="AdRotator.ascx" %>

 Links an assembly to the current page during compilation, making all the assembly's classes and interfaces available for use on the page. <%@ Assembly Name="MyAssembly" %><%@ Assembly Src="MySource.vb" %> 

Can a user browsing my Web site read my Web.config or Global.asax files?
No. The section of Machine.config, which holds the master configuration settings for ASP.NET, contains entries that map ASAX files, CONFIG files, and selected other file types to an HTTP handler named HttpForbiddenHandler, which fails attempts to retrieve the associated file. You can modify it by editing Machine.config or including an section in a local Web.config file. 


No comments:

Post a Comment