CSDN首页 空间 新闻 论坛 Blog 下载 读书 网摘 搜索 .NET Java 视频 接项目 求职 在线学习 买书 程序员 通知
山寨机中的战斗机! 程序优化工程师到底对IT界有没有贡献
CSDN社区
搜索 收藏 打印 关闭
CSDN社区 >  .NET技术 >  ASP.NET

online waiting~~ about Session Questions

楼主flycatcq(飞天猫)2004-05-02 17:19:40 在 .NET技术 / ASP.NET 提问

like   this:  
  one   .aspx  
  Session["Number_YN"]   =   intRandom;   //input   Session  
   
  other   .aspx  
  string   RintNum   =   Session["Number_YN"].ToString();  
  if(tbCodeNumber_Login.Text   !=   RintNum)  
  {  
          lblUserLoginErr.Text   =   "password   Err。";  
          return;  
  }  
  else  
  {  
          lblUserLoginErr.Text   =   "Done";  
  }  
   
  Questions:  
   
  1、Can   not   Load   Session   So   Can   not   to   compare  
   
  2、It's   Session   configuration   problem   I   think.But   my   configuration   it's   all   right.Web.config   like   this:  
  <sessionState   mode="InProc"   stateConnectionString="tcpip=127.0.0.1:42424"   sqlConnectionString="data   source=127.0.0.1;Trusted_Connection=yes"   cookieless="true"   timeout="20"   />  
  Global.asax   like   this:  
  protected   void   Session_Start(Object   sender,   EventArgs   e)  
  {  
            Session["Number_YN"]   =   "";  
  }  
   
  3、forgive   me   used   English   representation   the   problem.because   nohave   chinese   input.  
   
  thanks! 问题点数:50、回复次数:17Top

1 楼lxcc()回复于 2004-05-02 17:31:23 得分 5

现在没有环境,不知道那有问题,不过正常Session应该可以使用,你是否添加了命名空间  
  using   System.Web.SessionState;  
   
  要是还不行,可以试试Cache("")Top

2 楼smoothwood(吾谁与归)回复于 2004-05-02 17:31:52 得分 5

请贴出出错代码看看Top

3 楼flycatcq(飞天猫)回复于 2004-05-02 17:40:38 得分 0

now   using   XP   Professional   IE6.0   IIS   5.0   Visual   Studio.Net   Enterprise   Architect  
  It's   circumstances's   problem?Top

4 楼smoothwood(吾谁与归)回复于 2004-05-02 17:45:13 得分 5

有出错代码吗?或者是没有出错?  
   
   
  Top

5 楼flycatcq(飞天猫)回复于 2004-05-02 17:48:02 得分 0

languor!!Top

6 楼flycatcq(飞天猫)回复于 2004-05-02 17:48:41 得分 0

No   Err   Message   but   Can't   using   SessionTop

7 楼smx717616(又笨又不努力)回复于 2004-05-02 17:48:50 得分 0

please   paste   your   errorTop

8 楼smx717616(又笨又不努力)回复于 2004-05-02 17:51:44 得分 0

你确认启用了session   了吗?Top

9 楼flycatcq(飞天猫)回复于 2004-05-02 17:58:45 得分 0

using   System;  
  using   System.Collections;  
  using   System.ComponentModel;  
  using   System.Data;  
  using   System.Drawing;  
  using   System.Web;  
  using   System.Web.SessionState;  
  using   System.Web.UI;  
  using   System.Web.UI.WebControls;  
  using   System.Web.UI.HtmlControls;  
  using   System.Configuration;  
   
  namespace   TEST1  
  {  
  ///   <summary>  
  ///   index   的摘要说明。  
  ///   </summary>  
  public   class   index   :   System.Web.UI.Page  
  {  
  protected   System.Web.UI.WebControls.Label   lblUserLoginErr;  
  protected   System.Web.UI.WebControls.TextBox   tbUserName_Login;  
  protected   System.Web.UI.WebControls.TextBox   tbUserPassword_Login;  
  protected   System.Web.UI.WebControls.Button   btnUserLogin;  
  protected   System.Web.UI.WebControls.DropDownList   ddlUserType_Login;  
  protected   System.Web.UI.WebControls.Button   btnUserRegister;  
  protected   System.Web.UI.WebControls.Image   imageRandom;  
  protected   System.Web.UI.WebControls.TextBox   tbCodeNumber_Login;  
  protected   System.Web.UI.WebControls.Image   Image1;  
   
  private   void   Page_Load(object   sender,   System.EventArgs   e)  
  {  
  //   在此处放置用户代码以初始化页面  
  }  
   
  #region   Web   窗体设计器生成的代码  
  override   protected   void   OnInit(EventArgs   e)  
  {  
  //  
  //   CODEGEN:   该调用是   ASP.NET   Web   窗体设计器所必需的。  
  //  
  InitializeComponent();  
  base.OnInit(e);  
  }  
   
  ///   <summary>  
  ///   设计器支持所需的方法   -   不要使用代码编辑器修改  
  ///   此方法的内容。  
  ///   </summary>  
  private   void   InitializeComponent()  
  {          
  this.btnUserLogin.Click   +=   new   System.EventHandler(this.btnUserLogin_Click);  
  this.Load   +=   new   System.EventHandler(this.Page_Load);  
   
  }  
  #endregion  
   
  private   void   btnUserLogin_Click(object   sender,   System.EventArgs   e)  
  {  
  if(tbUserName_Login.Text.Length   <   1   ||   tbUserPassword_Login.Text.Length   <   1   ||   tbCodeNumber_Login.Text.Length   <   1)  
  {  
  lblUserLoginErr.Text   =   "Can't   Not   Empty";  
  return;  
  }  
  string   RintNum   =   Session["Number_YN"].ToString();  
  if(tbCodeNumber_Login.Text   !=   RintNum)  
  {  
  lblUserLoginErr.Text   =   "CodeNumber   Error";  
  return;  
  }  
  else  
  {  
  lblUserLoginErr.Text   =   "Done";  
  }  
  }  
  }  
  }  
   
  --------------------------------------------------------------------------------  
   
  using   System.Data;  
  using   System.Drawing;  
  using   System.Web;  
  using   System.Web.SessionState;  
  using   System.Web.UI;  
  using   System.Web.UI.WebControls;  
  using   System.Web.UI.HtmlControls;  
  using   System.Drawing.Imaging;  
  using   System.Drawing.Text;  
  using   System.IO;  
   
  namespace   TEST1  
  {  
  ///   <summary>  
  ///   RandomImage   的摘要说明。  
  ///   </summary>  
  public   class   RandomImage   :   System.Web.UI.Page  
  {  
  private   void   Page_Load(object   sender,   System.EventArgs   e)  
  {  
  //产生随机数  
  Random   ran   =   new   Random();  
  int   intRandom   =   ran.Next(1001,9999);  
  //将随机数(验证字串)写入Session  
  Session["Number_YN"]   =   intRandom;  
  //字体名  
  string   strFontName   =   "Arial";  
  //字体大小  
  int   intFontSize   =   9;  
  //图像宽  
  int   intWidth   =   40;  
  //图像长  
  int   intHeight   =   15;  
  //背景颜色  
  Color   bgColor   =   Color.White;  
  //前景颜色  
  Color   foreColor   =   Color.Black;  
  //产生字体  
  Font   forFont   =   new   Font(strFontName,intFontSize);  
  //生成图片  
  Bitmap   newBitmap   =   new   Bitmap(intWidth,intHeight,PixelFormat.Format32bppArgb);  
  Graphics   g   =   Graphics.FromImage(newBitmap);  
  //定义一个四方形框与字片一样大小  
  Rectangle   newRect   =   new   Rectangle(0,0,intWidth,intHeight);  
  //涂上背景色  
  g.FillRectangle(new   SolidBrush(bgColor),newRect);  
  //写字  
  g.DrawString(intRandom.ToString(),forFont,new   SolidBrush(foreColor),2,2);  
  MemoryStream   mStream   =   new   MemoryStream();  
  //存入MemoryStream  
  newBitmap.Save(mStream,ImageFormat.Gif);  
  g.Dispose();  
  newBitmap.Dispose();  
  //发送  
  Response.ClearContent();  
  Response.ContentType   =   "image/GIF";  
  Response.BinaryWrite(mStream.ToArray());  
  Response.End();  
  }  
  #region   Web   窗体设计器生成的代码  
  override   protected   void   OnInit(EventArgs   e)  
  {  
  //  
  //   CODEGEN:   该调用是   ASP.NET   Web   窗体设计器所必需的。  
  //  
  InitializeComponent();  
  base.OnInit(e);  
  }  
   
  ///   <summary>  
  ///   设计器支持所需的方法   -   不要使用代码编辑器修改  
  ///   此方法的内容。  
  ///   </summary>  
  private   void   InitializeComponent()  
  {          
  this.Load   +=   new   System.EventHandler(this.Page_Load);  
   
  }  
  #endregion  
  }  
  }  
   
  --------------------------------------------------------------------------------  
   
  <!--     会话状态设置  
                      默认情况下,ASP.NET   使用   Cookie   来标识哪些请求属于特定的会话。  
                      如果   Cookie   不可用,则可以通过将会话标识符添加到   URL   来跟踪会话。  
                    若要禁用   Cookie,请设置   sessionState   cookieless="true"。  
          -->  
          <sessionState   mode="InProc"   stateConnectionString="tcpip=127.0.0.1:42424"   sqlConnectionString="data   source=127.0.0.1;Trusted_Connection=yes"   cookieless="true"   timeout="20"   />  
   
  ---------------------------------------------------------------------------------  
   
  using   System;  
  using   System.Collections;  
  using   System.ComponentModel;  
  using   System.Web;  
  using   System.Web.SessionState;  
   
  namespace   TEST1    
  {  
  ///   <summary>  
  ///   Global   的摘要说明。  
  ///   </summary>  
  public   class   Global   :   System.Web.HttpApplication  
  {  
  ///   <summary>  
  ///   必需的设计器变量。  
  ///   </summary>  
  private   System.ComponentModel.IContainer   components   =   null;  
   
  public   Global()  
  {  
  InitializeComponent();  
  }  
   
  protected   void   Application_Start(Object   sender,   EventArgs   e)  
  {  
  Application["User_Count"]=0;  
  }  
     
  protected   void   Session_Start(Object   sender,   EventArgs   e)  
  {  
  Session["Number_YN"]   =   "";  
  }  
   
  protected   void   Application_BeginRequest(Object   sender,   EventArgs   e)  
  {  
   
  }  
   
  protected   void   Application_EndRequest(Object   sender,   EventArgs   e)  
  {  
   
  }  
   
  protected   void   Application_AuthenticateRequest(Object   sender,   EventArgs   e)  
  {  
   
  }  
   
  protected   void   Application_Error(Object   sender,   EventArgs   e)  
  {  
   
  }  
   
  protected   void   Session_End(Object   sender,   EventArgs   e)  
  {  
   
  }  
   
  protected   void   Application_End(Object   sender,   EventArgs   e)  
  {  
   
  }  
   
  #region   Web   窗体设计器生成的代码  
  ///   <summary>  
  ///   设计器支持所需的方法   -   不要使用代码编辑器修改  
  ///   此方法的内容。  
  ///   </summary>  
  private   void   InitializeComponent()  
  {          
  this.components   =   new   System.ComponentModel.Container();  
  }  
  #endregion  
  }  
  }  
   
  Top

10 楼smx717616(又笨又不努力)回复于 2004-05-02 18:05:05 得分 0

我没看你的代码,如果别的工程也不能用的话,就是你设置的  
  问题  
  在浏览器,工具--->Internet   选项,选取隐私,高级选项卡,选中覆盖自动   Cookie    
  处理,开启--->第一方接受,第三方接受。  
  Top

11 楼flycatcq(飞天猫)回复于 2004-05-02 18:14:23 得分 0

http://127.0.0.1/(ldsj3d45yzepd3bjehggrc2y)/index.aspx  
   
  Session   Not   to   Used  
  Top

12 楼flycatcq(飞天猫)回复于 2004-05-02 18:15:46 得分 0

Re:   smx717616(.Net┷我很菜)    
   
  I'm   Setup   OK   But   Session   Not   to   UsedTop

13 楼xrll()回复于 2004-05-02 18:41:30 得分 0

在web.config中:  
          <sessionState    
                          mode="InProc"  
                          stateConnectionString="tcpip=127.0.0.1:42424"  
                          sqlConnectionString="data   source=127.0.0.1;user   id=sa;password="  
                          cookieless="false"    
                          timeout="20"    
          />  
  Top

14 楼xrll()回复于 2004-05-02 18:44:33 得分 20

http://www.cnblogs.com/hover/articles/1283.aspxTop

15 楼flycatcq(飞天猫)回复于 2004-05-02 18:56:08 得分 0

languor!!   look   loseTop

16 楼smx717616(又笨又不努力)回复于 2004-05-02 19:51:22 得分 15

不可能呀,是不是开了防火墙什么的Top

17 楼flycatcq(飞天猫)回复于 2004-05-02 22:07:12 得分 0

all   ok   thank   you   ---xrll()---Top

相关问题

  • online waiting....help?
  • session?????????
  • Session
  • the problem of nfs and exports (waiting online)
  • cfile的偏移量??online waiting...
  • Help me, Help me ,help me , online waiting..........
  • online waiting for help! how can I do with the *.cpio
  • How to use Chinese Input in RedHat 7.3!!!!! (hurry!hurry! online waiting!)
  • help!hurry!help! Win2K can't boot!! (high score! online waiting!)
  • help!hurry!help! Win2K can't boot!! (high score! online waiting!)

关键词

  • .net
  • asp.net
  • 代码
  • 摘要
  • 字体
  • 修改
  • eventargs e
  • btnuserlogin
  • intrandom
  • protected

得分解答快速导航

  • 帖主:flycatcq
  • lxcc
  • smoothwood
  • smoothwood
  • xrll
  • smx717616

相关链接

  • CSDN .NET频道
  • .NET类图书
  • C#类图书
  • .NET类源码下载

广告也精彩

反馈

请通过下述方式给我们反馈
反馈
提问
网站简介|广告服务|VIP资费标准|银行汇款帐号|网站地图|帮助|联系方式|诚聘英才|English|问题报告
北京创新乐知广告有限公司 版权所有, 京 ICP 证 070598 号
世纪乐知(北京)网络技术有限公司 提供技术支持
Copyright © 2000-2008, CSDN.NET, All Rights Reserved
GongshangLogo