Tutorials Shared by the Internet Community
|Top Tutorials||New Tutorials||Submit||Login||Register|
Tutorial Basic Detail
Total Hits: 17053
Total Votes: 36 votes
Average Rating: 3.28 out of 5
Description: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.
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.
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.
What are the State Management Techniques used in ASP.NET?
State Management techniques used in ASP.NET can be categorized in two types:
Client-Side State Management
Server-Side State Management
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:
ViewState data is encoded in Base64 String encoded format.
Can we Enable/Disable ViewState?
Yes, ViewState can be enabled or disable at different levels:
ViewState for a specific control can be enabled or disabled by setting EnableViewState property as follows:
aControl.EnableViewState = false;
We can enable/disable ViewState for a complete page as follows:
<%@ Page Language="C#" EnableViewState="false" %>
For whole application, we can enable/disable views in configuration file as follows:
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.
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.
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();
Interview Questions about Session State Modes and Session_Start/Session_End events in Global.asax are already explained here.
What is the difference between Label Control and Literal Control?
A Label control in ASP.NET renders text inside 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.
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.
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 - ASP.NET Interview Questions for Beginners and Professionals - Part 2