ASP.NET - 保护变量 [英] ASP.NET - protected variable

查看:108
本文介绍了ASP.NET - 保护变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我用一个受保护的变量,变量能存在为整个Web应用程序或是否得到去除当用户移动到其他页面的GET或POST?我不知道这是不是在其他网页访问,除非我使用静态变量,但我很好奇,如果它存在于整个应用程序。请让我知道!

If I use a protected variable, does the variable exist for the whole web application or does it get removed when the user move to other page by get or post? I do know that it is not accessible in other pages unless I use static variable, but I am curious as to if it exists for the whole application. Please let me know!

推荐答案

当你移动到其他页面和回报,你的页面类的新实例将被创建,因此所有的非静态变量将被重置。

when you move to other page and return, a new instance of your page class will be created and so all non static variables will be reset.

该值将在一个请求过程续航时间有效(始于请求开始和结束时要求结束)

The value will be valid in a one request process life time (starts with request start and ends with request end)

做保护的变量,就意味着这个变量的访问能够继承类。例如在asp.net您可以在继承类使用它像您的标记里面(因为它继承了后面类code)

making a variable protected, just means that this variable is access-able in inherited class. for example in asp.net you can use it in inherited class like inside your markup (because it inherits code behind class)

这是受保护的变量的含义。

this is the meaning of protected variable

如果你想保留保存的网页之间的值,您可以使用您的具体要求,其中一个项目:

if you want to keep a value saved between pages you can use one of these items depending on your requirement :


  • 饼干

  • 查询字符串

  • 会话状态

  • 申请美国

  • 缓存

和ViewState中保持在同一页或控件回发之间的状态变量,而它不重定向到另一个页面。

and ViewState keeps state variable between postback in a same page or control while it is not redirected to another page.

这篇关于ASP.NET - 保护变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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