zoukankan      html  css  js  c++  java
  • C#中的ashx文件,用到Session,但是总无法获取Session,经过调试,出现的错误的原因:

    最近做一个项目,调用ashx文件,其中ashx文件里面有用到Session,但是总无法获取Session,经过调试,出现的错误的原因:

    大体如下

     context.Session[keyPic] = _fileNamePath;

    查阅MSDN得到ashx文件要使用Session,必须实现Session接口,如下

    public class PicUploadHander : IHttpHandler, System.Web.SessionState.IRequiresSessionState
    {
    
        string keyPic = "key";
        public void ProcessRequest (HttpContext context) {
                   try
            {
                        string _savedFileResult = UpLoadImage(_fileNamePath, context);
                context.Session[keyPic] = _fileNamePath;
                context.Response.Write(_savedFileResult);
            }
            catch
            {
                context.Session[keyPic] = null;
                context.Response.Write("上传提交出错");
            }
            
        }
  • 相关阅读:
    7、python数据类型之集合set
    python基本数据类型练习
    matplotlib
    numpy常用函数
    pillow包
    keras-tensorflow版本对应
    python-激活和切换运行环境
    端口监控
    numpy
    低风险创业笔记
  • 原文地址:https://www.cnblogs.com/spring_wang/p/3123489.html
Copyright © 2011-2022 走看看