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("上传提交出错");
            }
            
        }
  • 相关阅读:
    sklearn 数据预处理1: StandardScaler
    Gitlab利用Webhook实现Push代码后的Jenkins自动构建
    Shell脚本-自动化部署WEB
    Jenkins可用环境变量以及使用方法
    Docker常用命令
    nginx中root和alias的区别
    gitlab+jenkins=自动化构建
    Spring Boot2.0:使用Docker部署Spring Boot
    Maven内置属性、POM属性
    navicat连接mysql出现Client does not support authentication protocol requested by server解决方案
  • 原文地址:https://www.cnblogs.com/spring_wang/p/3123489.html
Copyright © 2011-2022 走看看