zoukankan      html  css  js  c++  java
  • 网络上实现单点登陆非application

    看了网上的一些方法,发用application,听我老大说很危险,我看说上的一个是用cache
    string str_Key = name.Text.Trim()+"_" + passwd.Text.Trim();
            string str_User = Convert.ToString(Cache[str_Key]);
            if (str_User == String.Empty)
            {
                TimeSpan SessTimeOut = new TimeSpan(0, 0, HttpContext.Current.Session.Timeout, 0, 0); HttpContext.Current.Cache.Insert(str_Key, str_Key, null, DateTime.MaxValue, SessTimeOut, CacheItemPriority.NotRemovable, null);
                Session["User"] = str_Key;
     Response.Write("<script>alert('登陆成功!')</script>");
            }
            else
            {
                Response.Write("<script>alert('抱歉,您好像已经登录了!)</script>");
                return;
            }

    我发现了一个bug,就是退出网站后,就进不去了。因为cache的时间是用session的时间定的,不能改变,当我吧Session["User"]设为null以后,cache还是有效,而其我用Cache的删除方法不能将相应键的对象删除,不知道各位有没有好的解决方法
    微软BI技术交流群:316744959 武汉NET技术群:961108969 NET技术群:21386099 本人具有丰富的系统开发经验,承接系统开发,小程序,NET系统开发,BI开发,有需求联系微信手机:15010195887
  • 相关阅读:
    mysql相关笔记
    qt杂项
    rpm离线安装整理
    linux fopen个数限制的问题(文件描述符限制)
    解决free():invalid pointer:0x00000000000000155455 ****的问题。
    linux c获取系统时间戳
    ubuntu QT Creater 安装
    LinkedHashMap如何保证顺序性
    HashMap原理(二) 扩容机制及存取原理
    HashMap原理(一) 概念和底层架构
  • 原文地址:https://www.cnblogs.com/Impulse/p/impulse.html
Copyright © 2011-2022 走看看