[Foreword:]asp.net is the latest technology for developing web-based applications from Microsoft.] It provides a number of benefits over traditional ASP scripting technologies, including:
(1) A better development structure is established by separating the UI presentation layer (presentation) from the commercial logic (business logic);
2 replaces traditional ASP code translation with fully compiled code;
3 It compiles features in conjunction with each supported method, which means that sites using ASP.net are more performance-efficient than traditional ASP sites.
While there are many potential benefits to converting existing ASP applications to ASP.net, some ASP application tasks are important and complex. The conversion process may require additional resources and pose additional risks to the application. One way to solve these problems is to run both ASP and ASP.net applications and convert a conversation to asp.net at one time. In order to run both old and new programs at the same time, it is necessary to establish a mechanism to share the state of conversation between traditional ASP and asp.net. This article discusses how to use. NET Framework components share state information with the class and serialization attributes.
Overview
Cookies are the most common way for Web applications to identify user conversations and can be used to identify traditional ASP and ASP.net dialog states. In ASP scripts, state information is stored in memory and cannot be shared with other applications, such as asp.net. If the dialog state is saved in a common format in Microsoft SQL Server, it can be accessed by traditional ASP and asp.net.
In this case, a cookie named mysession is used to identify user conversations. When a user makes a request to a Web application, a unique cookie is generated for that user to identify the conversation. In a subsequent request, the browser sends the unique cookie back to the server to identify the conversation. A custom object will use the unique cookie to reload user dialog data from SQL Server before the requested Web page is loaded. The dialog status in the Custom Object Web page is accessible. When the Web request completes, the dialog data is saved back to SQL Server if the request terminates (see Figure 1).
Figure 1. Simple Data Flow Diagram
640) this.width=640; "Border=0>
Asp. NET implementation
Each Web page in asp.net is derived from the System.Web.UI.Page class. The page class sets up an instance of the HttpSession object to process the dialog data. In this case, the custom page class, called Sessionpage, derives from System.Web.UI.Page, providing all the attributes similar to the page class. The only difference is that the default HttpSession uses a custom dialog object overload (using the new modifier for instance variables, C # allows derived classes to hide the members of the base class).
public class SessionPage:System.Web.UI.Page
{
...
Public new MySession session = NULL;
...
}
The custom dialog class uses the HybridDictionary object to save the dialog state in memory appropriately (HybridDictionary can be used to handle any number of dialog elements). For common use with traditional ASP, the custom Dialog object restricts the dialog data type to a string type (the default httpsession allows dialogs to hold any type of data, not common to traditional ASP).
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service