zoukankan      html  css  js  c++  java
  • 利用自定义类来管理网站用户登陆session版

    以前做asp的时候可以建一个文件然后写入判断session中的成员是否存在的语句,然后再include在管理员或会员要登陆的页中,现在做asp.net了也想了一个类似一个同样的方法。希望大家交流~~

    实现方法:

    一、自定义 SessionUser类
    /// <summary>
    /// SessionUser类 的摘要说明
    /// </summary>
    public class SessionUser
    {
        public SessionUser()
        {     
            if (HttpContext.Current.Session["user"] == null)
            {
                HttpContext.Current.Response.Write("<script>alert('对不起请你登陆!')</script>");
                HttpContext.Current.Response.Write("('对不起请你登陆!')");
                HttpContext.Current.Response.End();
            }
        }
    }

    二、调用文件中的Page_Loa方法来实例化

    protected void Page_Load(object sender, EventArgs e)
    {
       SessionUser login = new SessionUser();
    }

  • 相关阅读:
    ubuntu下如何更改mysql数据存放路径
    collection_select
    发现星期六日的电视比较好看
    rails
    系统抢救10.04
    劫后重生,痛定思痛,ubuntu 10.04=>10.10
    随机查询N条记录
    which linux your like
    kindeditor的使用
    array
  • 原文地址:https://www.cnblogs.com/astar/p/851150.html
Copyright © 2011-2022 走看看