• C#类中使用Session的正确方法


    这个类应该继承自System.Web.UI.Page

    using System;
    using System.Data;
    using System.Configuration;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Web.UI.HtmlControls;

    namespace AppName.App_Data
    {
    public class CheckLogin :System.Web.UI.Page
    {
    public CheckLogin()
    {
    object IsLogined = System.Web.HttpContext.Current.Session["IsLogined"];
    if (IsLogined != null)
    {
    if (IsLogined.ToString()!="1")
    {
    HttpContext.Current.Response.Write(
    "Error!");
    HttpContext.Current.Response.End();
    }
    else
    {
    HttpContext.Current.Response.Write(
    "OK");
    }
    }
    else {
    HttpContext.Current.Response.Write(
    "Error!");
    HttpContext.Current.Response.End();
    }

    }
    }
    }
  • 相关阅读:
    Swift 扩展
    Swift 类型转换
    Swift 自动引用计数(ARC)
    Swift 可选链
    Swift 析构过程
    Swift 构造过程
    Swift 继承
    Swift 下标脚本
    Swift 方法
    Swift 属性
  • 原文地址:https://www.cnblogs.com/leotian/p/1336484.html
Copyright © 2020-2023  润新知