ASP.NET Interview Questions for Beginners and Professionals – Part 1

By | March 30, 2014
This ASP.NET Tutorial is an extension to my previous tutorial “Top 10 ASP.NET Interview Questions and Answers“. In previous tutorial, focus was to present you with the most important and top ASP.NET Interview Questions that are normally asked during an ASP.NET developer Interview. Here in this article, I’ll try to further extend those important questions as well as add more important questions.

Basically, this is how an interviewer normally does? Interviewer asked a question about a technical concept at high level. If he gets a right answer, he further goes into details related to that particular concept and its implementation details.

For example, in previous article, we asked about the concept of View State in ASP.NET but in this tutorial, we will further explore the View State concept with more questions. But we will not repeat the questions already presented in previous post, so it’s highly recommended to go through that ASP.NET Interview Questions tutorial first.

You can follow other Parts of this ASP.NET Interview Questions Series as:

ASP.NET Interview Questions List – Part 1

What are HttpHandlers and HttpModules in ASP.NET?

In order to fully comprehend the concept of HttpHandlers and HttpModules, I have written a detailed ASP.NET Tutorial. Here I am defining both the concepts as follows:

HttpHandler: ASP.NET Engine uses HttpHandlers to handle specific requests on the basis of it’s extensions. ASP.NET Page Handler handles all requests coming for (.aspx) pages. We can define our own custom HttpHandler to handle a specific request with a specific extension, say .jpeg, .gif, or .ahmad. But there will always be only one handler for a specific request.

HttpModule: ASP.NET Engine uses HttpModules to inject some specific functionality along with ASP.NET default functionality for all incoming requests regardless of its extensions. There are a number of built-in modules already available in ASP.NET HTTP Pipeline. But we can write our own custom HTTP module to perform some additional functionality (for example, URL rewriting or implementing some security mechanism) for all incoming requests.

For more details about HttpHandlers and HttpModules in ASP.NET, you can follow MSDN link here.
Back to top

What is State Management?

HTTP is a stateless protocol by nature. So, we need some mechanism to preserve state (i.e. state of a webpage, a control or an object etc.) between subsequent requests to server from one or more clients. And this mechanism is referred as State Management.

Back to top

What are the State Management Techniques used in ASP.NET?

State Management techniques used in ASP.NET can be categorized in two types:

  1. Client-Side State Management
    • View State
    • Control State
    • Hidden Fields
    • Cookies
    • Query String
  2. Server-Side State Management
    • Application State
    • Session State
    • Profile Properties
    • Cache
ASP.NET State Management

Back to top

What is ViewState? or Explain ViewState as State Management Technique?

ViewState is one of the Client-Side State Management techniques that provides page-level state management, which means state is preserved between subsequent requests to same page. By using this technique, state of the page along with its controls is stored in a hidden form field  i.e. “__VIEWSTATE” and this field is again available on server when page is posted back with HTTP Request.
You can find this hidden field by looking into view source of an .ASPX page as:

<input type=”hidden” name=”__VIEWSTATE” value=”wEPDwUKMTM4OTIxNTEzNA9kFgJmD2QWAgIBD2QWAgIDDxYCHgVzdHlsZQV” />

ViewState data is encoded in Base64 String encoded format.
Back to top

Can we Enable/Disable ViewState?

Yes, ViewState can be enabled or disable at different levels:

  • Control Level
    ViewState for a specific control can be enabled or disabled by setting EnableViewState property as follows:
aControl.EnableViewState = false;
  • Page Level
    We can enable/disable ViewState for a complete page as follows:

    <%@ Page Language=”C#” EnableViewState=”false” %>
  • Application Level
    For whole application, we can enable/disable views in configuration file as follows:

    <pages enableViewState=”false”>
        ….
    </pages>

Back to top

What is the difference between Session.Clear() and Session.Abandon() in ASP.NET?

As we understand that Session is a Collection and it stores data as Key/Value pair. So,
Session.Clear() clears all the session values but doesn’t destroy the Session. however,
 Session.Abandon() destroys the session object.
In other words, Session.Clear() is like deleting all files inside a folder (say “Root”) but Session.Abandon() means deleting the “Root” folder.

Back to top

What is the difference between Application and Session State?

Application state is basically a common data repository for an application’s all users and their all sessions. On the other hand, Session state is specific to a single user session. Following diagram explains the difference between two state management techniques:Application Vs Session State Management
So, we can store data in application state object that is common for all users of a particular application as follows:

//Set Value
Application[“UsersCounter”] = Convert.ToInt32(Application[“UsersCounter”]) + 1;
//Retrieve Value
lblUsersCounter.Text = Application[“UsersCounter”].ToString();

It’s recommended to store smaller size values in application object.

Session object can store data for a specific session of user. Storage and retrieval is also simple just as for application object.

//Set Value
Session[“ProductsCount”] = Convert.ToInt32(Session[“ProductsCount”]) + 1;
//Retrieve Value
lblProductsCounter.Text = Session[“ProductsCount”].ToString();

Interview Questions about Session State Modes and Session_Start/Session_End events in Global.asax are already explained here.

Back to top

What is the difference between Label Control and Literal Control?

A Label control in ASP.NET renders text inside <span> tags while a Literal Control renders just the text without any tags.
With Label controls we can easily apply styles using it’s CssClass property, however, if we don’t want to apply style/formatting, it’s better to go for a Literal control.
Back to top

Hyperlink Vs LinkButton in ASP.NET?

A Hyperlink just redirects to a given URL identified by “NavigateURL” property. However a LinkButton which actually displays a Hyperlink style button causes a postback to the same page but it doesn’t redirect to a given URL.

Validation Controls related Interview Questions are already given in previous post here.
Back to top

Hopefully, this pool of ASP.NET Interview Questions and Answers along with previous list of Top 10 will be helpful for ASP.NET Developers.

Next to Part 2>>>

ASP.NET Online Test

Web Developer Interview Questions and Answers Series:

One thought on “ASP.NET Interview Questions for Beginners and Professionals – Part 1

Comments are closed.