Thursday, August 21, 2014

Describe state management in ASP.NET.



State management may be a technique to manage a state of Associate in Nursing object on totally different request.

The communications protocol protocol is that the basic protocol of the planet Wide net. communications protocol may be a homeless protocol means that each request is from new user with relevancy net server. communications protocol protocol doesn't give you with any technique of decisive whether or not any 2 requests square measure created by a similar person.

Maintaining state is very important in any net application. There square measure 2 styles of state management system in ASP.NET.

- Client-side state management
- Server-side state management
Explain shopper facet state management system.

ASP.NET provides many techniques for storing state info on the shopper. These embrace the following:

- read state ASP.NET uses read state to trace values in controls between page requests. It works inside the page solely. you can not use read state price in next page.

- management state: you'll persist info a few management that's not a part of the read state. If read state is disabled for an impact or the page, the management state can still work.

- hidden fields: It stores knowledge while not displaying that management and knowledge to the user’s browser. This knowledge is bestowed back to the server and is accessible once the shape is processed. Hidden fields knowledge is accessible inside the page solely (page-scoped data).

- Cookies:Cookies square measure little piece of data that server creates on the browser. Cookies store a worth within the user’s browser that the browser sends with each page request to the online server.

- question strings: In question strings, values square measure keep at the top of the address. These values square measure visible to the user through his or her browser’s address bar. question strings aren't secure. you must not send secret info through the question string.
Explain server facet state management system.

The following objects square measure accustomed store the data on the server:

- Application State:

This object stores the info that's accessible to any or all pages in a very given net application. the applying object contains international variables for your ASP.NET application.

- Cache Object: Caching is that the method of storing knowledge that's used oftentimes by the user. Caching will increase your application’s performance, quantifiability, and convenience. you'll catch the info on the server or shopper.

- Session State: Session object stores user-specific knowledge between individual requests. This object is same as application object however it stores the info regarding specific user.
Explain cookies with example.

A cookie may be a touch of information that server creates on the shopper. once an internet server creates a cookie, an extra communications protocol header is distributed to the browser once a page is served to the browser. The communications protocol header feels like this:

Set-Cookie: message=Hello. when a cookie has been created on a browser, whenever the browser requests a page from a similar application within the future, the browser sends a header that appears like this:

Cookie: message=Hello

Cookie is no little bit of text info. you'll store solely string values once employing a cookie. There square measure 2 styles of cookies:

- Session cookies
- Persistent cookies.

A cookie exists solely in memory. If a user closes the online browser, the cookie delete for good.

A persistent cookie, on the opposite hand, will offered for months or maybe years. after you produce a persistent cookie, the cookie is keep for good by the user’s browser on the user’s pc.

Creating cookie

protected void btnAdd_Click(object sender, EventArgs e)


// Here txtMsgCookie is that the ID of TextBox.
// cookie names square measure case sensitive. Cookie named message is totally different from setting a cookie named Message.

The on top of example creates a cookie. The cookie disappears after you shut your application program. If you would like to make a persistent cookie, then you wish to specify Associate in Nursing expiration date for the cookie.

Response.Cookies[“message”].Expires = DateTime.Now.AddYears(1);

Reading Cookies
void Page_Load()

// Here lblCookieValue is that the ID of Label management.
Describe the disadvantage of cookies.

- Cookie will store solely string price.
- Cookies square measure browser dependent.
- Cookies aren't secure.
- Cookies will store touch of information.

No comments: