静态属性在同一个应用程序中会有不同的值吗? [英] will Static property will have differnt values accross differnt sassion in same application ?

查看:84
本文介绍了静态属性在同一个应用程序中会有不同的值吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我的问题是,我以前使用静态属性,其中包含下拉列表中存在的下拉值。我试图从Web方法从用户控件父页访问此值。因为web方法只需要静态字段来获取值。



但我对这个静态属性的混乱是因为它会根据每个会话具有不同的值,或者它会包含所有uers的相同应用程序的相同值?

Hi ,

My question is that , i previously using static property which contains drop down value present in drop down . And i was trying to access this value from user controls parent page from Web method. As web method requires static fields only to get the value .

But i am in chaos regarding this static property is that will it have differnt values as per session or it will contain same value accross same application for all uers ??

推荐答案

使用 WebMethods 时,需要标记方法为静态。这样做是因为方法调用没有实例化 Page 类,这种情况发生在普通的Page PostBacks 中。这是Ajax Calls的实际好处。更多内容 - 为什么ASP.NET AJAX页面方法必须是静态的? [ ^ ]。



为什么在Web应用程序中使用静态属性?静态属性具有应用范围。因此,在尝试访问用户信息时,您最终会显示其他用户的详细信息。
While using WebMethods, you need to mark that method as Static. That is done because the method call does not instantiate the Page Class, which happens with normal Page PostBacks. That is the actual benefit of Ajax Calls. More at - Why do ASP.NET AJAX page methods have to be static?[^].

Why are you using Static properties in a Web App? Static properties have application scope. So, you will end up showing details of a different user while trying to access a User's information.


这篇关于静态属性在同一个应用程序中会有不同的值吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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