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.
You can follow other Parts of this ASP.NET Interview Questions Series as:
- ASP.NET Interview Questions – Part 1 (Controls, State Management etc.)
- ASP.NET Interview Questions – Part 2 (Controls, Globalization & Localization etc.)
- ASP.NET Interview Questions – Part 3 (Caching & Security etc.)
- ASP.NET Interview Questions – Part 4 (Security)
- ASP.NET Interview Questions – Part 5 (ASP.NET AJAX)
- ASP.NET Interview Questions – Part 6 (ASP.NET Web API)
ASP.NET Interview Questions List – Part 1
- What are HttpHandlers and HttpModules in ASP.NET?
- What is State Management?
- What are the State Management Techniques used in ASP.NET?
- What is ViewState? or Explain ViewState as State Management Technique?
- Can we Enable/Disable ViewState?
- What is the difference between Session.Clear() and Session.Abandon() in ASP.NET?
- What is the difference between Application and Session State?
- What is the difference between Label Control and Literal Control?
- Hyperlink Vs LinkButton 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.
State Management techniques used in ASP.NET can be categorized in two types:
- Client-Side State Management
- View State
- Control State
- Hidden Fields
- Query String
- Server-Side State Management
- Application State
- Session State
- Profile Properties
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:
ViewState data is encoded in Base64 String encoded format.
Back to top
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:
- 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”>
Session.Clear() clears all the session values but doesn’t destroy the Session. however,
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:
So, we can store data in application state object that is common for all users of a particular application as follows:
Application[“UsersCounter”] = Convert.ToInt32(Application[“UsersCounter”]) + 1;
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.
Session[“ProductsCount”] = Convert.ToInt32(Session[“ProductsCount”]) + 1;
lblProductsCounter.Text = Session[“ProductsCount”].ToString();
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
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.
Top 10 Interview Questions and Answers Series:
- Top 10 ASP.NET AJAX Interview Questions
- Top 10 WCF Interview Questions
- Comprehensive Series of WCF Interview Questions
- Top 10 HTML5 Interview Questions
- Top 10 ASP.NET Interview Questions
- Comprehensive Series of ASP.NET Interview Questions
- Top 10 ASP.NET MVC Interview Questions
- Top 10 ASP.NET Web API Interview Questions