日期:2014-05-17  浏览次数:20384 次

关于ashx页面session的赋值后的使用
在ashx页面以引用了 IRequiresSessionState, IReadOnlySessionState这两个,给sessin赋值但,    
public void ProcessRequest (HttpContext context) {
        ValidateNumber validate = new ValidateNumber();
        string validateCode = validate.CreateValidateNumber(4);
        context.Session["CheckCode"] = validateCode;

        CreateCodeImage(validateCode, context);
        validate.CreateValidateGraphic(context, validateCode);
    }
但是在login页面验证的时候还是为空为什么呢,是页面回发还是什么问题呢
        if (Session["CheckCode"] == null)
        {
            Utility.MessageBox.Show(this, "验证码不能为空!");
            this.TxtPwd.Text = string.Empty;
            this.txtCode.Text = string.Empty;
            return;
        }
session asp.net? 验证码 ashx 赋值

------解决方案--------------------
不需要继承IReadOnlySessionState这个接口就可以取的到 否则就会像你那样只能读session不能写
------解决方案--------------------
IRequiresSessionState
------解决方案--------------------
需要继承IRequiresSessionState