protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
Session["OrganCode"] = "Z";
}
for (int i = 0; i < 30000; i++)
{
string zstr = Session["OrganCode"].ToString();
if (string.IsNullOrEmpty(zstr))
{
Label1.Text = "session is null";
}
}
}
这样用,没有问题。
但类似的使用,在某些情况下,比如:用户点击转到其他页面时,会出现其中几个session为“”的情况。
改为
protected void Page_Load(object sender, EventArgs e)
{
// this.FormView3.ChangeMode(FormViewMode.ReadOnly);
if (!IsPostBack)
{
Session["OrganCode"] = "Z";
}
string zz= Session["OrganCode"].ToString();
for (int i = 0; i < 30000; i++)
{
string zstr = zz;
if (string.IsNullOrEmpty(zstr))
{
Label1.Text = "session is null";
}
}
}
all done!
Session乱用,即使不在乎性能,但也会有其他问题。所以说习惯还是要好才行。
Subscribe to:
Post Comments (Atom)
Search This Blog
Labels
news
China
society
Cheng Du
chengdu
live
economy
EARTH
Sichuan
entertainment
health
ET
dnn
medicine
tip
Children
Olympic Games
SOS
Tibet
module
school
ACTIVEX
RMB
Tibet incident
WSS
acupuncture
banting
compare
cure
enterprise forms
herbalist doctor
industry
integration
internet
meaningful
optimizing
question
.net
AIM / AOL
Android 灭鼠
Android 猪
CPPCC
Data delay load
Differencing disks
GoogleTalk
Holidays
ICQ
IM
IT
Interpersonal
MSDN programmer
MSN
NewSID
PLANET
Phishing
QQ
Session
TUS 翻墙 GFW
Traffic
Translation
UFO
VPC
What is the most regret in life
YAHOO
advantage
android
answer
aphorism
blog
born
business
cancer
conclusion
discuss
extraordinary memory
festival
film
fish
fo
fun
help
human
interesting
man
match
microsoft
music
new theory
old
photo
pidgin
plan
power
problem
procreate
relations
say
sharepoint
sid
solve
template
test
version
vs2010
wangboqiang
woman
words
四角号码在线查询
墙 GFW Android
开发 vs2008 vss2005 win2008
No comments:
Post a Comment