Thursday, June 3, 2010

ASP.Net Page Life Cycle

Page Life Cycle Stages:
page request
start
initialization
Load
Postback Even Handling
Rendering
Unload

Page Life Cycle Events:
Pre Init
Init
Init Complete
Pre Load
Load
Control Events
Load Complete
Pre-Render
Save State Complete
Render
Unload

Wednesday, June 2, 2010

What is State management

State management is the process by which you maintain state and page information over multiple requests for the same or different pges.

Types of State Management
There are two types State Management

1. Client-Side State Management
This stores information on the client's computer by embedding the information into a Web page, a uniform resource locator (url), or a cookie. The techniques available to store the state information at the client end are listed down below.

a. View State - Asp.Net uses View State to track the values in the Controls. You can add custome values to the view state. It is used by the Asp.Net page framework to automatically save the values of the page and of each control just prior to rendering to the page. When the page is posted, one of the first tasks performed by page processing is to restore view state.

b. Control State - If you create a custom control that requires view state to work properly, you should use control state to ensure other developers don't break your control by disabling view state.

c.Hidden fields - Like view state, hidden fields store data in an HTML form without displaying it in the user's browser. The data is available only when the form is processed.

d. Cookies - Cookies store a value in the user's browser that the browser sends with every page request to the same server. Cookies are the best way to store state data that must be available for multiple Web pages on a web site.

e. Query Strings - Query strings store values in the URL that are visible to the user. Use query strings when you want a user to be able to e-mail or instant message state data with a URL.

2. Server-Side State Management

a. Application State - Application State information is available to all pages, regardless of which user requests a page.

b. Session State - Session State information is available to all paes opened by a user during a single visit.

Both application state and session state information is lost when the application restarts. To persist user data between application restarts, you can store it using profile properties.

Example on Data Cache

What is View State

ViewState allows the state of objects (serializable) to be stored in a hidden field on the page. ViewState is transported to the client and back to the server, and is not stored on the server or any other external source.

View State :- Asp.Net uses View State to track the values in the Controls. You can add custom values to the view state. It is used by the Asp.net page framework to automatically save the values of the page and of each control just prior to rendering to the page. When the page is posted, one of the first tasks performed by page processing is to restore view state.

Example on try and catch

Tuesday, June 1, 2010

Difference between Ref vs. Out

The Ref and Our parameters are quiet similar, both parameters are used to return back some value to the caller of the function. But there is a main difference between this two is when we use the out parameter, the program calling the function need not assign a value to the out parameter before making the call to the function. The same is not true for the reference (ref) type parameter. For a ref type parameter, the value to the parameter has to be ssigned before calling the function. If we do not assign the value before calling the function we will get a compiler error.

Authorization in .Net

Authorization is the process of allowing an authenticated user access to resources. Authentication is always proceeds to Authorization; even if your application lets aonymous users connect and use the application, it still authenticates them as being anonymous.

Authentication in .Net

Authentication is the process of obtaining some sort of credentials from the users and using those credentials to verify the user's identity.