在网页中传递值 [英] Passing Values Among Web Pages

查看:93
本文介绍了在网页中传递值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我是asp.net的新手,我有一个项目需要我审核和评估。

我注意到代码包含声明:



session.contents(值名称)



当我搜索这个语句时,我理解这个语句在服务器上保存了一个值,只要代码再次调用它就可以返回。我是对的吗?



我这里有两个问题:

1-另一台机器无法访问此值吗?我的意思是当不同的用户在同一个应用程序上工作时,这些会话值之间不会发生冲突吗?我知道这可能是一个假问题,但我只是想确定我的评价。



2-当没有必要将值传递给其他页面时,页面中的局部和私有变量是否更好用?



有谁能告诉我关于会话价值的简短描述以及何时应该使用它以及何时不应该?



谢谢

Hi all,

I''m new with asp.net and i have a project that i need to review and evaluate.
I have noticed that the code contains the statement:

session.contents("value name")

When i searched about this statement i understood that this statement saves a value on the server and can be returned whenever the code call it again. am i right?

I have two questions here:
1- This value can not be accessed by another machine right? i mean when different users working on the same application, no conflicting will be occurred among these session values? i know it may be a dummy question but i just want to make sure of my evaluation.

2- When there is no need to pass a value to other pages, isn''t local and private variables within the page are better to use?

Can anyone tell me a brief description about the session values and when we should use it and when we shouldn''t?

Thanks

推荐答案

答案1)每个用户都会为会话值提供冲突。因此,如果有两个用户从不同的机器访问您的应用程序,则不会在它们之间共享此变量。



答案2)您是对的。当不需要共享值时,页面级别的本地和私有变量最好使用。



您应该尝试查找有关会话和应用程序级别变量的信息。网上有很多资源。试试这个:

http:// msdn .microsoft.com / zh-CN / library / ms524319(v = vs.90).aspx [ ^ ]
Answer 1) There will be no conflict as session values are served per user. So if there are two users accessing your applications from different machine, this variable will not be shared between them.

Answer 2) You are right. When there is no need to share values, local and private variables on page level are better to use.

You should try to find information about session and application level variables. There are plenty of resources online. Try this one:
http://msdn.microsoft.com/en-us/library/ms524319(v=vs.90).aspx[^]


你明白了。

1)会话变量存储在会话状态(对此有不同的支持机制),它们意味着分离会话ID标识的会话(:))。通常,会话ID是一个cookie,由服务器生成,发送到客户端,客户端随每个请求发送回来。因此,您可以在其中存储客户端特定数据(但不能太多)。当会话从代码中放弃或超时时,会话ID和会话状态将被销毁,永远丢失。但是有一个与会话相关的线程,称为会话劫持,当攻击者窃取/猜测其他客户端的会话ID,从而进入他/她的会话,并访问其他客户端具有的权限。在此上下文中,客户端可以是命名的或匿名的临时用户。

2)会话变量用于保持会话中的值。因此,在处理单个请求期间使用它来存储必要的东西是浪费资源。



但ASP.NET处理管道比简单的CGI(例如PHP)更复杂,我建议你阅读这篇文章以获得更深入的观点:http://www.west-wind.com/presentations/howaspnetworks/howaspnetworks.asp [ ^ ]


这篇关于在网页中传递值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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