变量在一个页面,它是共享? [英] Variable in a page, is it shared?

查看:100
本文介绍了变量在一个页面,它是共享?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

基本上我有1套管理页面。我可以使用一个会话变量,每个用户的GUID,以确保编辑正确的数据库信息。

Basically I have 1 set of admin pages. I can use a session variable with each users GUID, to make sure to edit the proper DB information.

如果有说5人编辑使用了一个的ArrayList ,将的ArrayList 共享例如一个页面所有的人对其进行编辑,或将页面各个版本都有自己的本地的ArrayList ?我是否需要做出某种一切会话变量,因此数据不能混淆与其他用户?

If there are say 5 people editing a page that uses for example an ArrayList, will the ArrayList be shared by all people editing it, or will each version of the page have its own local ArrayList? Do I need to make everything session variables of some kind so data does not get mixed up with that of other users?

推荐答案

在ASP.NET。该页面每次你问的时间呈现。如果你创建一个的ArrayList 里,这将是活着只为特定页面呈现循环。它将被立即呈现页面丢失。

In ASP.NET. The page is rendered every time you ask to. If you create an ArrayList inside, it will be alive only for that particular page render cycle. It will be lost as soon as the page is rendered.

使用在你的页面静态变量保持变量活着是一个糟糕的主意,因为他们将继续活了会议。常规变量将消失在页面呈现循环结束。如果你想持久化数据仅在用户会话,使用<一个href="http://msdn.microsoft.com/en-us/library/system.web.sessionstate.httpsessionstate(v=vs.110).aspx"相对=nofollow> HttpContext.Current.Session 对象保存的会话状态

Using static variables inside your page to keep variables alive is a bad idea since they will keep alive over sessions. Regular variables will be gone as the page render cycle ended. If you want to persist data for the user's session only, use the HttpContext.Current.Session object to save the Session State.

这篇关于变量在一个页面,它是共享?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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