Page

Interview Questions in ASP.NET,C#.NET,SQL Server.

1.Describe state management in ASP.NET.
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

2.Explain client side state management system.
ASP.NET provides several techniques for storing state information on the client. These include the following:
View state ASP.NET uses view state to track values in controls between page requests. It works within the page only. You cannot use view state value in next page.

Control state: You can persist information about a control that is not part of the view state. If view state is disabled for a control or the page, the control state will still work.

Hidden fields: It stores data without displaying that control and data to the user’s browser. This data is presented back to the server and is available when the form is processed. Hidden fields data is available within the page only (page-scoped data).

Cookies:Cookies are small piece of information that server creates on the browser. Cookies store a value in the user’s browser that the browser sends with every page request to the web server.


Query strings: In query strings, values are stored at the end of the URL. These values are visible to the user through his or her browser’s address bar. Query strings are not secure. You should not send secret information through the query string.

3.Explain server side state management system.
The following objects are used to store the information on the server:
Application State:This object stores the data that is accessible to all pages in a given Web application. The Application object contains global variables for your ASP.NET application.

Cache Object: Caching is the process of storing data that is used frequently by the user. Caching increases your application’s performance, scalability, and availability. You can catch the data on the server or client.


Session State: Session object stores user-specific data between individual requests. This object is same as application object but it stores the data about particular user.

4.Explain cookies with example.
A cookie is a small amount of data that server creates on the client. When a web server creates a cookie, an additional HTTP header is sent to the browser when a page is served to the browser. The HTTP header looks like this:

Set-Cookie: message=Hello. After a cookie has been created on a browser, whenever the browser requests a page from the same application in the future, the browser sends a header that looks like this:

Cookie: message=Hello

Cookie is little bit of text information. You can store only string values when using a cookie. There are two types of cookies:

Session cookies 
Persistent cookies

A session cookie exists only in memory. If a user closes the web browser, the session cookie delete permanently.

A persistent cookie, on the other hand, can available for months or even years. When you create a persistent cookie, the cookie is stored permanently by the user’s browser on the user’s computer.

Creating cookie
protected void btnAdd_Click(object sender, EventArgs e) 
{
    Response.Cookies[“message”].Value = txtMsgCookie.Text; 
}
// Here txtMsgCookie is the ID of TextBox. 
// cookie names are case sensitive. Cookie named message is different from setting a cookie named Message.

The above example creates a session cookie. The cookie disappears when you close your web browser. If you want to create a persistent cookie, then you need to specify an expiration date for the cookie.

Response.Cookies[“message”].Expires = DateTime.Now.AddYears(1);
Reading Cookies
void Page_Load() 
{
if (Request.Cookies[“message”] != null) 
lblCookieValue.Text = Request.Cookies[“message”].Value; 
}

// Here lblCookieValue is the ID of Label Control.

5.Describe the disadvantage of cookies.
Cookie can store only string value.
Cookies are browser dependent.
Cookies are not secure.

Cookies can store small amount of data.

6.What is Session object? Describe in detail.

HTTP is a stateless protocol; it can't hold the user information on web page. If user inserts some information, and move to the next page, that data will be lost and user would not able to retrieve the information. For accessing that information we have to store information. Session provides that facility to store information on server memory. It can support any type of object to store. For every user Session data store separately means session is user specific.


7.What are the Advantages and Disadvantages of Session?
Following are the basic advantages and disadvantages of using session.

Advantages:
It stores user states and data to all over the application.
Easy mechanism to implement and we can store any kind of object.
Stores every user data separately.
Session is secure and transparent from user because session object is stored on the server.

Disadvantages:
Performance overhead in case of large number of user, because of session data stored in server memory.
Overhead involved in serializing and De-Serializing session Data. Because In case of StateServer and SQLServer session mode we need to serialize the object before store.

8.Describe the Master Page.
Master pages in ASP.NET works as a template that you can reference this page in all other content pages. Master pages enable you to define the look and feel of all the pages in your site in a single location. If you have done changes in master page, then the changes will reflect in all the web pages that reference master pages. When users request the content pages, they merge with the master page to produce output that combines the layout of the master page with the content from the content page.



ContentPlaceHolder control is available only on master page. You can use more than one ContentPlaceHolder control in master page. 

9. What are the various types of validation controls provided by ASP.NET?
ASP.NET provides 6 types of validation controls as listed below:

i.) RequiredFieldValidator - It is used when you do not want the container to be empty. It checks if the control has any value or not. 

ii.) RangeValidator - It checks if the value in validated control is within the specified range or not. 

iii.) CompareValidator - Checks if the value in controls matches some specific values or not. 

iv.) RegularExpressionValidator - Checks if the value matches a specific regular expression or not.

v.) CustomValidator - Used to define User Defined validation.

vi.) Validation Summary - Displays summary of all current validation errors on an ASP.NET page.


10. What are the various types of Authentication?
There are 3 types of Authentication namely Windows, Forms and Passport Authentication.

Windows authentication - It uses the security features integrated in Windows NT and Windows XP OS to authenticate and authorize Web application users.

Forms authentication - It allows you to create your own list of users and validate their identity when they visit the Web site.

Passport authentication - It uses the Microsoft centralized authentication provider to identify users. Passport allows users to use a single identity across multiple Web applications. Passport SDK needs to be installed to use Passport authentication in your Web application.

11. Explain Server-side scripting and Client-side scripting.

Server side scripting - All the script are executed by the server and interpreted as needed. 

Client side scripting means that the script will be executed immediately in the browser such as form field validation, email validation, etc. It is usaullaycarrried out in VBScript or JavaScript.

12. What is garbage collection?
It is a system where a run-time component takes responsibility for managing the lifetime of objects and the heap memory that they occupy.

13. Explain the steps to be followed to use Passport authentication.
1. Install the Passport SDK. 
2. Set the application’s authentication mode to Passport in Web.config. 
3. Set authorization to deny unauthenticated users.
3. Use the PassportAuthentication_OnAuthenticate event to access the user’s Passport profile to identify and authorize the user.
4. Implement a sign-out procedure to remove Passport cookies from the user’s machine.


14. Explain the advantages of ASP.NET.
Following are the advantages of ASP.NET.

1.Web application exists in compiled form on the server so the execution speed is faster as compared to the interpreted scripts.

2.ASP.NET makes development simpler and easier to maintain with an event-driven, server-side programming model.

3.Being part of .Framework, it has access to all the features of .Net Framework.

4.Content and program logic are separated which reduces the inconveniences of program maintenance.

5.ASP.NET makes for easy deployment. There is no need to register components because the configuration information is built-in.

6.To develop program logic, a developer can choose to write their code in more than 25 .Net languages including VB.Net, C#, JScript.Net etc.

7.Introduction of view state helps in maintaining state of the controls automatically between the postbacks events.

8.ASP.NET offers built-in security features through windows authentication or other authentication methods.

9.Integrated with ADO.NET.

15. What are the Web Form Events available in ASP.NET?
1. Page_Init
2. Page_Load
3. Page_PreRender
4. Page_Unload
5. Page_Disposed
6. Page_Error
7. Page_AbortTransaction
8. Page_CommitTransaction
9. Page_DataBinding











No comments:

Post a Comment