asp.net中的状态管理 [英] state management in asp.net

查看:75
本文介绍了asp.net中的状态管理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我正在asp.net状态管理中学习和练习。

你能不能给我一些基本而简单的状态管理示例(会话) ,cookie,查询字符串,查看状态和应用程序管理)。



谢谢...,

解决方案

< blockquote> 客户端:

查看状态 - Asp.Net使用视图状态来跟踪控件中的值。您可以将自定义值添加到视图状态。 Asp.net页面框架使用它在呈现到页面之前自动保存页面和每个控件的值。发布页面时,页面处理执行的第一个任务之一是恢复视图状态。

控制状态 - 如果创建需要视图状态才能正常工作的自定义控件,则应使用控件状态以确保其他开发人员不会通过禁用视图来中断控制州。

隐藏字段 - 与视图状态类似,隐藏字段以HTML格式存储数据,而不在用户的浏览器中显示。只有在处理表单时才能使用该数据。

Cookies - Cookies在用户浏览器中存储一个值,浏览器将每个页面请求发送到同一服务器。 Cookie是存储必须可用于网站上多个网页的状态数据的最佳方式。

查询字符串 - 查询字符串存储URL中对用户可见的值。如果希望用户能够通过URL发送电子邮件或即时消息状态数据,请使用查询字符串。



服务器端:

申请状态 - 申请状态信息可用于所有页面,无论哪个用户请求页面。

会话状态 - 会话状态信息可供用户在一次访问期间打开的所有页面使用。

应用程序重启时,应用程序状态和会话状态信息都会丢失。要在应用程序重新启动之间保留用户数据,可以使用配置文件属性存储它。



您可以通过MSDN获得更详细的描述: ASP.NET状态管理概述 [ ^ ]



另请查看这些CP文章:

初学者ASP.NET中的状态管理技术简介 [ ^ ]

状态管理和处理Web场/ Web园场景中缓存的方法 [ ^ ]

初学者查看状态指南 [ ^ ]

演练到应用程序状态 [ ^ ]

状态管理 [ ^ ]


hi,
I'm learning and practicing on asp.net state management.
can you please provide me some basic and simple examples of state-management (sessions , cookies, query string , view state and application management).

thank you...,

解决方案

Client Side:
View State – Asp.Net uses View State to track the values in the Controls. You can add custom values to the view state. It is used by the Asp.net page framework to automatically save the values of the page and of each control just prior to rendering to the page. When the page is posted, one of the first tasks performed by page processing is to restore view state.
Control State – If you create a custom control that requires view state to work properly, you should use control state to ensure other developers don’t break your control by disabling view state.
Hidden fields – Like view state, hidden fields store data in an HTML form without displaying it in the user's browser. The data is available only when the form is processed.
Cookies – Cookies store a value in the user's browser that the browser sends with every page request to the same server. Cookies are the best way to store state data that must be available for multiple Web pages on a web site.
Query Strings - Query strings store values in the URL that are visible to the user. Use query strings when you want a user to be able to e-mail or instant message state data with a URL.

Server Side:
Application State - Application State information is available to all pages, regardless of which user requests a page.
Session State – Session State information is available to all pages opened by a user during a single visit.
Both application state and session state information is lost when the application restarts. To persist user data between application restarts, you can store it using profile properties.

You can get more detailed description over MSDN: ASP.NET State Management Overview[^]

Also check out these CP articles:
Beginners Introduction to State Management Techniques in ASP.NET[^]
State management and ways to handle Cache in a Web Farm/Web Garden scenario[^]
Beginner's Guide To View State [^]
A Walkthrough to Application State[^]
State Management[^]


这篇关于asp.net中的状态管理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆