Monday, May 28, 2012

Interview questions of viewstate

Different types of state management?

There are two different types of state management:
  1. Client Side State Management
    • View State
    • Hidden Field
    • Cookies
    • Control State
  2. Server Side State Management
    • Session
    • Application Object
    • Caching
    • Database
What is View State ?
View state is Client Side StateManagement ,
View State will stores the page value during the post back to the server.
It will stores the page value in Base64 Encoded Stiring which is suitable for HTTP Protocols
View state will allows you to store the value of form controls in every post back to the server.
View state will store the value in Hidden fields .So we need to use seriliaztion .


Where is view state stored?

View state will store the value of page control in a string .
We can store the view state for a control as below syntax:
ViewState["Variable"]=Textbox.Text;
We can retreive the view state value as below syntax :
string Test=ViewState["Variable"];


How can we Enable and Disable the view state 
We can able to Enable and Disable the view state in Page Level as will as Application Level

Page Level :
EnavbleViewState=”False”


  

On doing so we can able to Enable/Disable the view state in Page Level
We can Enable view state on writing code in cs file as below
TextBox1.EnableViewState =true;


Application Level :
We can able to Enable/Disable the view state in Application Level as below :
in web.config file :
<system.web>
<pages enableViewState="true"> </pages>



How we can Trace the view state Information ?
We can able to Trace the Viewstate Information by just Enabling the Trace option
In page attributes Trace=”True”

    After Tracing How we can view the view state Information 
1.Run the Application where you strored the view state 
2.When the Aspx page is running in browser ,Right click and select “View Source “
you can able to see the view state Information as below Image

                     

How to Provied Security for View state ?
We can approch the functionality as 2 steps.
1.By Just Adding a simple attributes in page level – EnableviewstateMac=”True”
2.We can encript the view state data by adding the attribute in page level- ViewStateEncryptionMode="Always/Auto/Never" 

EnableviewstateMac=”True”
ViewStateEncryptionMode="Always"


Advantages of view state ?
1.View state is very easy to implement , 
2.We can able to store any kind of value in string
No server resource is required for this because it is client side Management.


Disadvantage of View state ?
1.Date was not that much secure because it is just Base64 Encoded string , it is very easy to hack .
2.When the view state data is in large amount it may causes application performance issue.

Wednesday, May 9, 2012

Types of session Modes in ASP. Net


In sessions we have 4 Types of session Modes in ASP. Net
  1. In- Proc Mode
  2. State Server Mode
  3. SQL Server Mode
  4. Custom Mode


    Session Mode
    State Provider
    In-Proc
    In Proc will store the date In Memory Object
    State Server
    State Serve will store the date in Asp net_state.exe
    SQL Server
    It Store the data in SQL Serve Data base
    Custom
    It stores the data in custom provider

What is session ID in sessions


The ASP.NET session state is a technology that lets you store server-side, user-specific data.
ASP. Net uses 120Bit identifier to track each session ID.
When the Client hits the website some information was stored in session .then session will create a unique session ID from the client in session state provider.
Server looks on session provider and retrieve the serialized data from state serve and type cast the object.

What is Session in State Management


Sessions are so secure and Transferred , On using sessions in asp.net we can able to transfer the date from on page to the another page ,
We can able to store any kind of data in the session object
Sessions are always server side memory ,because client request to the server and can be able to read the data from server itself. Session objects are stored in session state provider.

Advantages:
  • Sessions are secure to transfer the data
  • We can able to store any kind of object in session variable
  • sessions are used to transfer the data from one page to the another page
Disadvantages
  • Sessions are having so many limitations , When large number of users are using the same application it may causes performance issue due to increase of traffic   

What is State Management in ASP.Net 4.0


Asp. Net State Management offers you the Techniques like
1.Client Side Management
2.Server Side Management

Server Side Management
Sessions State
Application State

Client Side Management
Hidden Files
Cookies
View State
Query String 

State Management in ASP.Net 4.0

1. What is State Management ?
2. What is Session in State Management ?
3. Advantages and Disadvantages in Sessions
4. What is Session ID ?
5. Types of Sessions Modes in State Management ?
6. What is state Provider ?