.Net Interview Questions and Answers – Part 8

71. What is the use of base keyword? Tell me a practical example for base keyword’s usage?
The base keyword is used to access members of the base class from within a derived class:
* Call a method on the base class that has been overridden by another method.
* Specify which base-class constructor should be called when creating instances of the derived class.

A base class access is permitted only in a constructor, an instance method, or an instance property accessor.
It is an error to use the base keyword from within a static method.
Example:In this example, both the base class, Person, and the derived class, Employee, have a method named Getinfo. By using the base keyword,
it is possible to call the Getinfo method on the base class, from within the derived class.

// keywords_base.cs
// Accessing base class members

 using System;  
 public class Person  
 protected string ssn = "444-55-6666";  
 protected string name = "John L. Malgraine";  
 public virtual void GetInfo()  
 Console.WriteLine("Name: {0}", name);  
 Console.WriteLine("SSN: {0}", ssn);  
 class Employee: Person  
 public string id = "ABC567EFG";  
 public override void GetInfo()  
 // Calling the base class GetInfo method:  
 Console.WriteLine("Employee ID: {0}", id);  
 class TestClass {  
 public static void Main()  
 Employee E = new Employee();  

72.  What are the different.NET tools which you used in projects?
Ans:Just read your question once again and thought Interviewer might be asking about the development tool you have used to develop ASP.NET projects.
So your answer can be Visual Studio 2005 or 2008 or 2010 whatever you have used, you may also tell Visual Web Developer or any other tool you might
have used to develop your ASP.NET Project.

73 .  What is asp.net life cycle ?
Life Cycle Events
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.

74. How the request is handled by IIS ?
We give an URL to an aspx page in the browser address bar and press enter. What happens next? We get the response in terms of rendered HTML but how?

  1. We are requesting something from the browser, which means indirectly we are requesting something from the Web Server, that means IIS. IIS, based on the file extension, decides which ISAPI extension can serve the request.And in case of ASP.Net (.aspx) it will be aspnet_isapi_dll so the request is passed to it for processing.
  2. When the first request comes to the website,an application domain is created by the ApplicationManager class where exactly the website runs, and which creates an isolation between 2 web applications.
    Within the application domain an instance of the HostingEnvironment class is created which provides access information about the application such as the name of the folder where the application is stored.
  3. Next ASP.Net creates core objects like HttpContext, HttpRequest,HttpResponse.
  4. Finally the application starts by creating an instance of the HttpApplication Class (which can be reused for multiple requests to maximize performance).

75. What is Difference between Session and Cookies  ? 
The basic and main difference between cookie and session is that cookies are stored in the user’s browser but sessions can’t store in user’s browser. This specifies which is best used for.

• A cookie can keep all the information in the client’s browser until deleted. If a person has a login and password, this can be set as a cookie in their browser so they do not have to re-login to your website every time they visit. You can store almost anything in a browser cookie.

• Sessions are not reliant on the user allowing a cookie. They work like a token in the browser which allowing access and passing information while the user has opened his browser. The problem in sessions is when you close the browser the session will automatically lost. So, if you had a site requiring a login, this couldn’t be saved as a session but it can be saved as a cookie, and the user has to re-login every time they visit.
cookies are nothing but a small piece of information on the client machine. before we create a cookies we should check whether the cookies are allowed at the browser side. They are limited in a size 4k.(they are 2 types of cookies peristant cookie , and session cookies)

Sessions cookies are stored in a server memory during the client browser session.When the browser is closed the session cookies are lost.

76. Advantages and disadvantages of Session?
Following are the basic advantages and disadvantages of using session. I have describe in details with each type of session at later point of time.


  • It helps maintain user state and data all over the application.
  • It is easy to implement and we can store any kind of object.
  • Stores client data separately.
  • Session is secure and transparent from the user.


  • Performance overhead in case of large volumes of data/user, because session data is stored in server memory.
  • Overhead involved in serializing and de-serializing session data, because in the case of StateServer and SQLServer session modes, we need to serialize the objects before storing them.

Besides these, there are many advantages and disadvantages of session that are based on the session type. I have discussed all of them in the respective sections below.

Sign-up for our email newsletter and get free job alerts, current affairs and GK updates regularly.
Subscribe Here (or)

Leave a Reply

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

three + = 5

Popup Dialog Box Powered By : XYZScripts.com
  • RSS
  • Facebook
  • Google+
  • Twitter