Building Microsoft ASP.NET Applications for Mobile Devices, Second Edition [Electronic resources] نسخه متنی

اینجــــا یک کتابخانه دیجیتالی است

با بیش از 100000 منبع الکترونیکی رایگان به زبان فارسی ، عربی و انگلیسی

Building Microsoft ASP.NET Applications for Mobile Devices, Second Edition [Electronic resources] - نسخه متنی

Andy Wigley; Peter Roxburgh

نمايش فراداده ، افزودن یک نقد و بررسی
افزودن به کتابخانه شخصی
ارسال به دوستان
جستجو در متن کتاب
بیشتر
تنظیمات قلم

فونت

اندازه قلم

+ - پیش فرض

حالت نمایش

روز نیمروز شب
جستجو در لغت نامه
بیشتر
افزودن یادداشت
افزودن یادداشت جدید






Chapter 12: State Management


Overview


When you build dynamic Web applications, you usually need a mechanism to store information between client requests. Unfortunately, HTTP is effectively stateless, which means you must maintain state in some other way. In the past, developers often used cookies to track—and thus identify—a user with a session ID and to reconcile information stored on the server to that user. For example, Active Server Pages (ASP) used cookies to track users and stored information relevant to each user in a Session object. Although ASP's use of cookies was a powerful method for maintaining state, it isn't always appropriate with wireless devices because many of them don't support cookies.

On the other hand, Microsoft ASP.NET offers a range of mechanisms for maintaining state, some of them built on the foundations of ASP. In this chapter, you'll learn about four significant techniques ASP.NET offers for preserving state:



Session stateAllows you to maintain the variables and objects for a client over the course of multiple requests and responses.



Hidden variablesAllow you to persist objects between server round-trips by posting the data to the client as hidden fields.



ViewStateAllows you to maintain the values of a mobile Web Forms page on the server. The runtime stores this information in an instance of the System.Web.UI.StateBag class, which is itself stored within the Session. However, as you'll learn later in this chapter, in the section "ViewState," the server sends some information to the client.



Application stateAllows you to maintain the variables and objects of an application over multiple requests by multiple clients.



The first three of these techniques require that the server be able to identify the client so that it can track multiple request-response interactions between the server and the same client. This requires that some kind of unique token is sent to the client with each server response, which the client then returns to the server with its next request. With regular desktop browsers, this is usually done using HTTP cookies, but many small mobile devices do not support cookies. ASP.NET uses munged URLs for clients that don't support cookies. Munged URLs are URLs that the runtime modifies to contain a unique session ID. We'll discuss munged URLs later in this chapter, in the section "Using Munged URLs."

/ 145