Sunday 29 January 2017

ASP.NET interview questions Part-1

1. Ques: Brief about ASP.NET Page Life Cycle ?
Answer: 
Page request
Page Start
Page Initialization
Page Load
Postback event handling
Page Rendering
Page Unload


2. Ques: Brief about ASP.NET Page Life Cycle event ?
Answer: 
The following lists are the asp.net page life-cycle events.
1.PreInit event
2.Init event
3.InitComplete event
4.PreLoad event
5.Load event
6.LoadComplete
7.PreRender event
8.PreRenderComplete event
9.SaveStateComplete event
10 Render event
11.Unload event

PreInit:  PreInit is the first event in asp.net page life cycle.
               it set a master page dynamically.
               it set the theme property dynamically.
               it create or re-create dynamic controls.
               IsCallback and IsCrossPagePostBack properties have also been set in this event.
               Read or set profile property values.

Init: This event called when you can initialize your page controls property.

InitComplete: This event Raised at the end of the page's initialization stage. InitComplete event allows tracking of view state.

PreLoad: This event viewstate starts retrieving their values from controls.

Load: This Load event is raised for the page first and then recursively for all child controls.

Control: This events raised  to handle specific control events, such as a Button control's Click event.

LoadComplete: This events raised after loading process is completed.

PreRender: This events raised just before the output is rendered.

PreRenderComplete: This events raised after output is completed.

SaveStateComplete: This events saved the view state information.

Render: This is not an event; instead, at this stage of processing HTML of your page writes out the control's markup to send to the browser.

Unload: This events is last event that gets fired in Page Life Cycle .this event use for cleaning process like closing the open file connections etc..


3. Ques :  What is State Management in ASP.NET.? How many are State Managements and explain them.
Answer: 
State management is the process that maintain state of control and page over multiple requests for the same or different pages.

There are two types of state management techniques  in ASP.Net
Client side state management
  • Hidden Field
  • View State
  • Cookies    
  • Query Strings
Server side state management
  • Session 
  • Application
Client side state management

Hidden Field: 
 Hidden Fields are small amounts of data on the client side.
 It does not get displayed on the UI(browser).
 It Contains a small amount of memory.
 No server resource required.

View State: 
View State use preserve page and control values between round trips.
 It is Page-Level State Management technique .when request go from one page to other page                View State data lost.
 It Can store any type of data.
 View State use for to track the values in the Controls in asp.net.

Cookies: 
A small text file that is stored in the user's browser.
If new session created then A new cookie will be generated and store your browser until you           close your browser.
Generally cookie is used to identify users.and it Store information temporarily.
Cookies are not good for storing sensitive data.
       
 Two type of Cookie
Persist Cookie - A cookie has not have expired time Which is called as Persist Cookie.it                    exist on hard drive until you erase them or they expire
(Session cookies) Non-Persist Cookie - These cookies are saved in memory and will be lost               while closing your browser.
A new session cookie will be generated, which will store your browsing information and will             be active until you leave the site and close your browser.

Query Strings:
Query String sent information to the server by URL that are visible to the user.
It is way to transfer information from one page to another through the URL.
It store the value in the form of Key-Value pair.

Server side state management 
Session:Session state stores user specific information and the information is visible within that session only. sessions are stored in server memory called as In-Process.and sessions are stored out server memory called out- Proc.Session object store any type of data.

Application: The data stored in an application object can be Access by all user of the application.
The application object stores data in the key value pair.Data stored in the application object should be of small size.


5. Ques :What are the different types of sessions in ASP.Net? Explain them.
Answer: 
Session Management can be achieved in two ways

1) InProc
2) OutProc

OutProc is again two types
a)State Server
b)SQL Server

InProc: It stores state in Web server memory. This is the default sessions sate.
Advantages:
1) Faster as session resides in the same process as the application
2) No need to serialize the data

 Dis Advantages:
1) Will degrade the performance of the application if large chunk of data is stored
2) On restart of IIS all the Session info will be lost


State Serve: Stores session state in a separate process called the  state service.
Advantages:
1) Faster then SQL Server session management
2) Safer then InProc. As IIS restart session data not lost.
3) won't effect the session data

Dis Advantages.:
1) Data need to be serialized
2) On restart of ASP.NET State Service session info will be lost
3) Slower as compared to InProc.

SQL Server: Session state store in a SQL Server database.
Advantages
1) Reliable and Durable.
2) IIS and ASP.NET State Service restart won't effect the session data
3) Good place for storing large chunk of data

Dis Advantages:
1) Data need to be serialized
2) Slower as compare to InProc and State Server
3) Need to purchase Licensed version of SQL Serve


6. Ques : What is the difference between GET method() and POST method()?
Answer
GET method( )

  • Data is affixed to the URL.
  • Data is not secured.
  • Data transmission is faster in this
  • This is a single call system.
  • Only limited amount of data can
  • be sent.
  • It is a default method for many
  • browsers.

POST method( )

  • Data is not affixed to the URL.
  • Data is secured.
  • Data transmission is comparatively slow.
  • This is a two call system
  • Large amount of data can be sent.
  • It is not set as default. it should be explicitly specified.

No comments:

Post a Comment

Thank you for comment