悬赏园豆:30
[已关闭问题]
<P>最近要实现一个功能,想保存用户最近查询的数据,网址:<A title=http://www.vvcha.cn/huoche.aspx href="http://www.vvcha.cn/huoche.aspx" target=_blank><FONT color=#800080>http://www.vvcha.cn/huoche.aspx</FONT></A> <BR></P>
<P>我的实现方法: <BR><BR>1. 定义了一个类A,在A里面定义了一个数组,提供了数据添加的方法add() 。 <BR>2. 在Application_Start里面示例化这个类,并把实例化后的对象保存到application里面。 <BR> A a=new A(); <BR> Application["zhuangtai"] = a; <BR><BR>3.在用户查询后,把a取出来,调用相关的方法 <BR> A a=(A)Application["zhuangtai"]; <BR> a.add(); //把用户输入的查询数据添加到类A的数组里面。 <BR>4.在需要显示的页面,取出a中的数据。 <BR> <BR>问题:发现用户查询的数据只能保存很短的时间,不知道什么原因? </P>
<P>类A的代码<BR></P>
<DIV class=cnblogs_code><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/None.gif" align=top><SPAN style="COLOR: #0000ff">public</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">class</SPAN><SPAN style="COLOR: #000000"> A<BR><IMG id=Codehighlighter1_19_492_Open_Image onclick="this.style.display='none'; document.getElementById('Codehighlighter1_19_492_Open_Text').style.display='none'; document.getElementById('Codehighlighter1_19_492_Closed_Image').style.display='inline'; document.getElementById('Codehighlighter1_19_492_Closed_Text').style.display='inline';" src="http://space.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif" align=top><IMG id=Codehighlighter1_19_492_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; document.getElementById('Codehighlighter1_19_492_Closed_Text').style.display='none'; document.getElementById('Codehighlighter1_19_492_Open_Image').style.display='inline'; document.getElementById('Codehighlighter1_19_492_Open_Text').style.display='inline';" src="http://space.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif" align=top> </SPAN><SPAN id=Codehighlighter1_19_492_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://space.cnblogs.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_19_492_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align=top> <BR><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align=top><BR><IMG id=Codehighlighter1_74_99_Open_Image onclick="this.style.display='none'; document.getElementById('Codehighlighter1_74_99_Open_Text').style.display='none'; document.getElementById('Codehighlighter1_74_99_Closed_Image').style.display='inline'; document.getElementById('Codehighlighter1_74_99_Closed_Text').style.display='inline';" src="http://space.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_74_99_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; document.getElementById('Codehighlighter1_74_99_Closed_Text').style.display='none'; document.getElementById('Codehighlighter1_74_99_Open_Image').style.display='inline'; document.getElementById('Codehighlighter1_74_99_Open_Text').style.display='inline';" src="http://space.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif" align=top> </SPAN><SPAN style="COLOR: #0000ff">private</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">string</SPAN><SPAN style="COLOR: #000000">[] ary </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #0000ff">new</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">string</SPAN><SPAN style="COLOR: #000000">[]</SPAN><SPAN id=Codehighlighter1_74_99_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://space.cnblogs.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_74_99_Open_Text><SPAN style="COLOR: #000000">{</SPAN><SPAN style="COLOR: #800000">""</SPAN><SPAN style="COLOR: #000000">,</SPAN><SPAN style="COLOR: #800000">""</SPAN><SPAN style="COLOR: #000000">,</SPAN><SPAN style="COLOR: #800000">""</SPAN><SPAN style="COLOR: #000000">,</SPAN><SPAN style="COLOR: #800000">""</SPAN><SPAN style="COLOR: #000000">,</SPAN><SPAN style="COLOR: #800000">""</SPAN><SPAN style="COLOR: #000000">,</SPAN><SPAN style="COLOR: #800000">""</SPAN><SPAN style="COLOR: #000000">,</SPAN><SPAN style="COLOR: #800000">""</SPAN><SPAN style="COLOR: #000000">,</SPAN><SPAN style="COLOR: #800000">""</SPAN><SPAN style="COLOR: #000000">}</SPAN></SPAN><SPAN style="COLOR: #000000"> ;<BR><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align=top><BR><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align=top> </SPAN><SPAN style="COLOR: #0000ff">private</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">int</SPAN><SPAN style="COLOR: #000000"> count1;<BR><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align=top> <BR><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align=top><BR><IMG id=Codehighlighter1_170_204_Open_Image onclick="this.style.display='none'; document.getElementById('Codehighlighter1_170_204_Open_Text').style.display='none'; document.getElementById('Codehighlighter1_170_204_Closed_Image').style.display='inline'; document.getElementById('Codehighlighter1_170_204_Closed_Text').style.display='inline';" src="http://space.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_170_204_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; document.getElementById('Codehighlighter1_170_204_Closed_Text').style.display='none'; document.getElementById('Codehighlighter1_170_204_Open_Image').style.display='inline'; document.getElementById('Codehighlighter1_170_204_Open_Text').style.display='inline';" src="http://space.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif" align=top> </SPAN><SPAN style="COLOR: #0000ff">public</SPAN><SPAN style="COLOR: #000000"> zhuangtai() </SPAN><SPAN id=Codehighlighter1_170_204_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://space.cnblogs.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_170_204_Open_Text><SPAN style="COLOR: #000000">{ <BR><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align=top> count1</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #800080">0</SPAN><SPAN style="COLOR: #000000">;<BR><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top> }</SPAN></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align=top><BR><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align=top><BR><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align=top><BR><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align=top> </SPAN><SPAN style="COLOR: #0000ff">public</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">void</SPAN><SPAN style="COLOR: #000000"> Datain( </SPAN><SPAN style="COLOR: #0000ff">string</SPAN><SPAN style="COLOR: #000000"> tmp)<BR><IMG id=Codehighlighter1_256_379_Open_Image onclick="this.style.display='none'; document.getElementById('Codehighlighter1_256_379_Open_Text').style.display='none'; document.getElementById('Codehighlighter1_256_379_Closed_Image').style.display='inline'; document.getElementById('Codehighlighter1_256_379_Closed_Text').style.display='inline';" src="http://space.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_256_379_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; document.getElementById('Codehighlighter1_256_379_Closed_Text').style.display='none'; document.getElementById('Codehighlighter1_256_379_Open_Image').style.display='inline'; document.getElementById('Codehighlighter1_256_379_Open_Text').style.display='inline';" src="http://space.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif" align=top> </SPAN><SPAN id=Codehighlighter1_256_379_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://space.cnblogs.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_256_379_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align=top> ary[count1] </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> tmp;<BR><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align=top> count1 </SPAN><SPAN style="COLOR: #000000">+=</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #800080">1</SPAN><SPAN style="COLOR: #000000">;<BR><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align=top> </SPAN><SPAN style="COLOR: #0000ff">if</SPAN><SPAN style="COLOR: #000000"> (count1 </SPAN><SPAN style="COLOR: #000000">></SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #800080">7</SPAN><SPAN style="COLOR: #000000">)<BR><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align=top> count1 </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #800080">0</SPAN><SPAN style="COLOR: #000000">;<BR><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top> }</SPAN></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align=top> </SPAN><SPAN style="COLOR: #0000ff">public</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">string</SPAN><SPAN style="COLOR: #000000"> Dataout( </SPAN><SPAN style="COLOR: #0000ff">int</SPAN><SPAN style="COLOR: #000000"> shuju)<BR><IMG id=Codehighlighter1_431_484_Open_Image onclick="this.style.display='none'; document.getElementById('Codehighlighter1_431_484_Open_Text').style.display='none'; document.getElementById('Codehighlighter1_431_484_Closed_Image').style.display='inline'; document.getElementById('Codehighlighter1_431_484_Closed_Text').style.display='inline';" src="http://space.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_431_484_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; document.getElementById('Codehighlighter1_431_484_Closed_Text').style.display='none'; document.getElementById('Codehighlighter1_431_484_Open_Image').style.display='inline'; document.getElementById('Codehighlighter1_431_484_Open_Text').style.display='inline';" src="http://space.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif" align=top> </SPAN><SPAN id=Codehighlighter1_431_484_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://space.cnblogs.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_431_484_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align=top> </SPAN><SPAN style="COLOR: #0000ff">return</SPAN><SPAN style="COLOR: #000000"> ary[shuju].ToString();<BR><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top> }</SPAN></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align=top><BR><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align=top><BR><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/ExpandedBlockEnd.gif" align=top> }</SPAN></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/None.gif" align=top><BR><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/None.gif" align=top></SPAN></DIV>