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
  • 相关阅读:
    es6---let和const
    node.js开发指南系列(1)partial is not defined
    input唤起键盘影响移动端底部fixed定位
    vue滑动吸顶以及锚点定位
    nodejs开发准备工作(2)
    nodejs开发准备工作(1)
    php基础小知识
    php基础
    git基础
    ps基础
  • 原文地址:https://www.cnblogs.com/Impulse/p/impulse.html
Copyright © 2011-2022 走看看