Top 10 ASP.NET Interview Questions and Answers – Tips for Hiring ASP.NET Developers

State management is a technique to manage a state of an object on different request.

The HTTP protocol is the fundamental protocol of the World Wide Web. HTTP is a stateless protocol means every request is from new user with respect to web server. HTTP protocol does not provide you with any method of determining whether any two requests are made by the same person.

Maintaining state is important in any web application. There are two types of state management system in ASP.NET.

  1. Client-side state management
  2. Server-side state management

Que1. What methods are fired during page load?

Ans: 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.
Que2. When during the page processing cycle is view state available ?
Ans: – After the Init() and before the Page_load() or Onload() for a control.
Que3. What is event Bubbling ? (Bubbled event)
Ans: – Server controls like Datagrid, Datalist, and Repeater can have other child controls inside them. These child control do not raise their 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 “Item_Command” event. As the child control send their events to parent this is termed as event bubbling.
Que4. What is the Global.aspx used for ?
Ans: – The Global.aspx (including the Global.aspx.cs file) is used to implement application and session level events.
Que 5. What is difference between Server.Transfer and Response.Redirect?
Ans: 1. Response.Redirect – This tells the browser that the requested page can
be found at a new location. The browser then initiates another request to the new page loading its contents in the browser. This results in two requests by the browser.
Server.Transfer – It transfers execution from the first page to the second page on the server. As far as the browser client is concerned it made one request and the initial page is the one responding with content. The benefit of this approach is one less round trip to the server from the client browser.
2. Using Server.Transfer you can redirect only on the same server’s page (like to This cross server redirect is possible only using Response.Redirect.
3. With Server.Transfer you can preserve your information. It has a parameter called as “preserveForm”. So the existing query string posted form variables are available to the second page as well.
Note – If you are navigating within the same website use Server.Transfer or else go for Response.Redirect.
Que6. What is a Session and Application Object ?

Ans: – Session object store information between HTTP requests for a particular user, while application object are global across users.

Que7. Explain the differences between Server-side and client-side code ?
Ans: – Server side code is executed at the server-side on IIS in ASP.NET framework, while client side code is executed on the browser.
Que8. What is ViewState ?
Ans: – ViewState is used to retain the state of server-side objects between postbacks. ViewState allows the state of objects to be stored in a hidden field on the page. ViewState is transported to the client and back to the server and is not stored on the server or any other external source.
Que9. List the types of Authentication supported by ASP.NET ?
Ans: – You can use one of these modes in web.config file –
<authentication mode = “windows”>
<authentication mode = “passport”>
<authentication mode = “forms”>
Windows Authentication: – IIS provides windows authentication. IIS gives you a choice out of (Anonymous, Basic, digest & windows integrated) (User must provide a windows username and password)
Passport Authentication: – Passport authentication lets you to use Microsoft’s passport service to authenticate users of your application.
Forms Authentication: – Forms authentication provides you with a way to handle authentication using your own custom logic with in an ASP.NET application.
Into <Web.config> file –
<Authentication mode=”Forms”>
<forms name=”wrox” loginUrl=”login.aspx” path=”/” />
<deny users=”&” />
Que10. What are the different types of Session State management options
available with ASP.NET ?
Ans: – ASP.NET provides In-Process and Out–of-process state management. In–process stores the session in memory on the web server. This requires the a ”Sticky-server” (or no load-balancing) so that the user is always reconnected to the same web server .Out–of-process session state management stores data in an external data source.
The external data source may be either a SOL server or a state server service. Out–of-process state management requires that all objects stored in session are serializable.
Que11. What Base class do all Web Forms inherit from ?
Ans: – The Page Class (
Que12. What method do you use to explicitly kill a user’s session?
Ans: – Session.Abandon
Que13. How do you turn off cookies for one page in your site?
Ans: – Set the Cookie.Discard Property to true.
Que14. What is PostBack?
Ans: – A PostBack is just that a posting back to the same page. The PostBack contains all the form information collected on the initial page for processing if required. Because of all the PostBack that can occur with an ASP.NET page you want to know whether a request is the first instance for a particular page or is a PostBack from the same page. You can make this check by using the IsPostBack property of the Page class.
If (Page.IspostBack == true)
// Do Processing
If (!IsPostBack)
{ // Do Processing }
Que15. In the case of cross-page posting in Next page how can we use data of previous page ?
Ans: – In first page
PostBackUrl = “Page2.aspx”;
In Second Page
Protected void Page_Load()
TextBox Tx1;
Tx1 = (TextBox) PrevousPage.FindControl (“TextBox1”);
Label1.Text = Tx1.Text ;
Que16. What is CLR ?
Ans: – Common Language Runtime (CLR) is a run-time environment that manages the execution of .NET code and provides services like memory management, debugging security etc. The CLR is also known as Virtual Execution System (VES).
Que17. What is CIL ?
Ans: – The CIL is a set of specification for a runtime environment including a Common Type System base class library and a Machine Independent Intermediate code known as the Common Intermediate Language (CIL).
Que18. What is Data Binding ?
Ans: – Data binding is a way used to connect values from a collection of data (e.g. Dataset) to the controls on a web form.
Que19. Describe Paging in ASP.NET?
Ans: – The Datagrid control in ASP.NET enables easy paging of the data. The AllowPaging property of the Datagrid can be set to true to perform paging. ASP.NET automatically performs paging and provides the hyperlinks to the other page in different styles based on property that has been set for PagerStyle Mode.
Que20. What is an Assembly?
Ans: – An assembly consists of one or more files (dll’s, exe’s, html files etc.) and represent a group of resources type definitions and implementations of these 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 this making the assembly 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. Multiple versions can be deployed side by side in different folder. Two types of assemblies –
1. Private Assembly – A private assembly is normally used by a single application and is stored in the application’s directory or a sub-directory beneath.
2. Shared Assembly (Public Assembly) – A shared assembly is normally stored in the Global Assembly Cache (GAC), which is a repository of assemblies maintained by the .NET runtime. Shared assemblies are usually libraries of code which many applications will find useful e.g.
crystal report classes.
Que21. What is NameSpace ?
Ans: – NameSpace has two basic functionality –
1. NameSpace logically group types, example Sytem.web.UI logically group our UI (User Interface) related features.
2. In Object–Oriented world many times it’s possible that programmers will use the same class name. By qualifying NameSpace with class name this collision can be avoided.
Que22. List the ASP.NET validation controls ?
Ans: – 1. RequiredFieldValidator – It check whether the control have any value.
It’s used when you want the control should not be empty.
2. RangeValidator – It checks if the value in validated control is in that specific range.
3. CompareValidator – It check that the value in controls should match some specific value.
4. RegularExpressionValidator – for e-mail address checking (according to a specific regular expression)
5. CustomValidotor – for user defined validation.
6. ValidationSummary – It viewing summary of all current validation errors.
Que23. Is ASP.NET 64-Bit enabled ? And How ?
Ans: – Another big area of change in ASP.NET is in the area of performance and scalability. ASP.NET 2.0 now provides 64-bit support. This means that you can now run your ASP.NET application on 64-bit Intel or AMD processors. Because ASP.NET 2.0 is fully backward compatible with ASP.NET 1.0 and 1.1 you can now take any former ASP.NET application recompile the application on the .NET Framework 2.0 and run it on a 64-bit processor.
Que24. Explain how Caching in ASP.NET 2.0 ? (What type of Caching ?)
Ans: – Caching stores frequently accessed data in memory where it can be retrieved faster than it could be from a file or database. ASP.NET provides two different types of caching –
1. Application Caching – A collection that can store any object in memory and automatically remove the object based on memory limitations, time limits or other dependencies.
To use the application cache, add and retrieve objects from the cache collection. A single cache object exists for each application so items in the cache can be shared between user sessions and requests. Before using a cached value stored in the cache collection you must verify that it is not null. If a value is null that value either hasn’t been cached or it has expired. Therefore you must retrieve the object from the original source rather than from cache.
Cache[“Greeting”] = “Hello, world ! “;
If (cache[“Greeting”] != null)
Value = (string) cache[“Greeting”];
Value = “Hello, world !”;
For example the following code sample demonstrates how to make a cache dependency based on a file. If the file changes the object is removed from cache.
Cache.Insert(“FileCache” , ”cacheContents” , New
System.web.Caching.CachDependancy (Server.mapPath(“SourceFile.xml”)));
2. Page Output Caching – ASP.NET can store a copy of rendered pages to reduce the time required to render the page in future requests.
<%@ outputcache Duration=”15” varyByparam=”name” %>
Que25. What is Partial classes?
Ans: – The code – behind files in ASP.NET 2.0 use a new language feature called partial classes, which allow code – behind files to be dynamically compiled with their associated .aspx pages into a single class type.
Que26. How to secure your connection string in web.config file?
Ans: <ConnectionStrings>
<add name=”conn” ConnectionString=”……”/>
To encrypt – (in Visual Studio 2005 command prompt)
* aspnet_regiis –pef “ConnectionStrings” “fullpath”
If changes are made to the connectionStrings section using the GUI tools, the new connection is encrypted which means that you won’t have to run the aspnet_regiis utility again.

You can decrypt the connectionStrings section by using the following command


Free Exclusive Traffic Tips

About the Author: Dharmendra Yadav

Dharmendra Yadav is a PHP developer. Dharmendra Yadav background includes B.Tech in Computer Science and Engineering. Currently he is working with CORE PHP, CODEIGNITER, , Laravel, Opencart, JAVASCRIPT, JQUERY, AJAX, WORDPRESS, WEB API technologies , Smarty.

You May Also Like

Leave a Reply

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