STATE MANGEMENT


We can divide State mangement options can be divided into following categories : Client Side State Mangament, Server Side State Management, and Database.

Client-State management -

1) View State

The ViewState property of an ASP.Net enables you to retain pages and control specific values between round trips. ASP.Net uses viewstate property to automatically save the values of web page and each control on web page prior to rendering the page.

Syntax - ViewState["ABC"] = "Any Value";

Advantages :Values stored in standard HTML format as a part of web page, Values in viewstate are hashed, compressed and encoded for unicode implementations.

Disadvantages : Storing large values can cause page to slow down when users display it or post it, Values are stored in hidden field in a page and can be tampered.

2) Hidden Field

In Asp.net, you can use the HTML-Standard hidden fields in a web formto store page-specific information. When a page is submitted to server, the content of hidden field is sent in the HTTPForm collection along with the values of other controls. In Asp.Net the HtmlInputHidden controls provide the hidden field functionality.

Advantages : Can store page specific information without accessing an Web Server and Web Browser resources, Easily implemented in Asp.net web forms, you just need to add HttpInputHidden control to a web page and use Value property of control.

Disadvantages : You can view the values stored in web pages by accessing source of web page, Hidden field cannot store more than a single value field to store information and Storig large value can slow down the processing of page.

3) Cookies

A cookie is used to store small peice of information on client machine. A cookie contains page specific information that web server sends to a client along with page output.

Cookies are saved on client computer and can either be Temporary or Persistent. Temporary cookies, also known as session cookies exists in memory space of browser. When browser is closed , all session cookies added to browser will be lost. Persistent Cookies, is saved as a text file in a file system of client computer.

Advantages : Easy to create and maintain, No server resources is involved in maintainance of cookie and Either expires when browser session ends or exists indefinetly in client computer

Disadvantages : They have limited size and most browser alllows cookies to have maximum 4096 bytes in size, Can be tampered because cookies are stored in client computer and User can disable cookies.

4) QueryString

If you need to submit information back to webpage or another page by using URL, you can use querystring.

Advantages : No server resource is involved to process a querystring, Many web browsers supports passing value in querystring.

Disadvantages : Information is directly visible to user in browser window. Therefore you need to encrypt this information. There is limit to amount of information that you store, most browser supoorts 255 characters.


Server-State management -

1) Application State :

Asp.net provides Application State as a means of storing application wide specific information such as objects and variables. The information in Application State is stored in key value pairs and is used to maintain consistency between server round trips and between pages. Application state is started when each browser request is made for specific URL. After Application State is created, the application specific information is stored in it.

Since Application state variables are global to an application, it is important to consider following issues while storing the value : The memory occupied by variable is not released until the value is either removed or replaced. Therefore number of variable and objects in application state should be minimumm and Explicit synchronization method should be used to avoid deadlocks and access violations, because many pages can access values stored in an application state simultanesouly.

Advantages : Easy to use and is consistent with other .net framework classes, and Storing information in application state involves maintaining a single copy of information.

Disadvantages : Data stored in application state is lost when web server fails due to server crash, upgrade or shut down, and Request server memory and can affect the performance of server.

2) Session State :

Session state is used to store session specific information for a website. Unlike application state, scope of session is limited to current browser session. If different users are accessing a web application, each will have different session state.

A unique 120 bit SessionId string containing ASCII characters identifies and tracks each active Asp.net session. The SessionId strings are communicated across client server requests either by means of HTTP cookie or by using a modified URL with embedded SessionId string.

By default a session variable is active for 20 minutes without any user interaction.

Advatages : Session state is event driven. Therefore you can use session events to perform conditional execution of user defined tasks, and Session state can survive web server restart without losing session data, because data is stored in another process.

Disadvantages : Stored in memory untill they are either removed or replaced, which can degrade the Web server performance.

Database Support -

In adddition to client side and server side, Asp.net also provide database support to maintain state on your website. It is used to store specific information where the information store is large. It is particulary useful for maintaing long term state or state which should be preserved even if the server must be restarted.

Advantages :Security and Consistency

Disadvantages : Database support in state management involves complex hardware and software configurations and Performance of web site can go down due to poor construction of relational data model.




WEB SERVICE
Web Service can be described as combination of one or more methods. We can integrated web service with one or more applications, regardless of any Programming Language, hardware and software platforms used to develop them.

Main benefits of Web Service are they can easily integrate with any application; these applications can exchange data using Web Service. Other benefit is Web Service is easily accessible over Internet and also you can integrate them with different applications.

Elements of Web Service are:-

XML (Extensible Markup Language) - XML developed by W3C, is most commonly used data format for sharing and exchanging data between different applications.

SOAP (Simple Object Access Protocol) - SOAP is the common protocol for making communication between Web Service and Client Application.

WSDL (Web Services Description Language) - WSDL is the markup language that best describes the Web Service and can be used to understand the methods and parameter used by clients in Web service.

UDDI (Universal Description Discovery and Integration) - Web Services are register in UDDI directory by provider, and this UDDI contains pointers to Web Service and WSDL document used for Web Service.