Monday, May 30, 2011

Asp.net Tech/web Services

ASP.NET application life cycle and events processing 

A web application starts when a browser requests a page of the application first time. The request is received by the IIS which then starts ASP.NET worker process (aspnet_wp.exe). The worker process then allocates a process space to the assembly and loads it. An application_start event occurs followed by Session_start. The request is then processed by the ASP.NET engine and sends back response in the form of HTML. The user receives the response in the form of page.

The page can be submitted to the server for further processing. The page submitting triggers postback event that causes the browser to send the page data, also called as view state to the server. When server receives view state, it creates new instance of the web form. The data is then restored from the view state to the control of the web form in Page_Init event.
The data in the control is then available in the Page_load event of the web form. The cached event is then handled and finally the event that caused the postback is processed. The web form is then destroyed. When the user stops using the application, Session_end event occurs and session ends. The default session time is 20 minutes. The application ends when no user accessing the application and this triggers Application_End event. Finally all the resources of the application are reclaimed by the Garbage collector.

Explain the ASP.NET page lifecycle.  

 

Lifecycle of a page in ASP.NET follows following steps:
Page_Init(Initialization of the page) >> LoadViewState(loading of View State) >> LoadPostData(Postback data processing) >> Page_Load(Loading of page) >> RaisePostDataChangedEvent(PostBack change notification) >> RaisePostBackEvent (PostBack event handling) >> Page_PreRender (Page Pre Rendering Phase) >> SaveViewState (View state saving) >> Page_Render (Page rendering) >> Page_UnLoad (Page unloading)

 ----------------------------------------------------------------------------------

DataSet Vs DataReader

  • DataSet Object works under Disconnected mode, While DataReader Object has Connected mode.
  • DataSet Object has Read/Write access, While DataReader Object has Read-only access.
  • DataSet Object Supports multiple tables from different databases, While DataReader Object Supports a single table based on a single SQL query of one database.
  • DataSet Object has Greater overhead to enable additional features, While DataReader Object being Lightweight object with very little overhead.
  • DataSet Object is Bind to multiple controls, While DataReader Object is Bind to a single control.
  • DataSet Object supports Forward and backward scanning of data, While DataReader Object supports Forward-only scanning of data.
  • DataSet Object has Slower access to data, While DataReader Object has Faster access to data.
  • DataSet Object is Supported by Visual Studio .NET tools, While DataReader Object Must be manually coded. 
Machine Vs Webconfig

Machine.config:
1. The configurations mentioned in machine.config file are applicable to all the applications hosted in a machine/computer/server.

2. The machine.config file is located in x:\\Microsoft.NET\Framework\\config\machine.config

3. There can be only one machine.config file per machine (per dotnet framework installed).

web.config:
1. web.config file contains configurations for a single application.

2. Web.config files overrides the configurations mentioned in machine.config file.

3. The web configuration file is located in your application's root folder

4. There can be multiple web.config files in a single web application in different sub folders.