欧美大屁股bbbbxxxx,狼人大香伊蕉国产www亚洲,男ji大巴进入女人的视频小说,男人把ji大巴放进女人免费视频,免费情侣作爱视频

歡迎來到入門教程網(wǎng)!

C#教程

當(dāng)前位置:主頁 > 軟件編程 > C#教程 >

C#程序中session的基本設(shè)置示例及清除session的方法

來源:本站原創(chuàng)|時間:2020-01-10|欄目:C#教程|點擊: 次

session的基本設(shè)置:

using System;
using System.Collections.Generic;
using System.Text;
using System.Web;
using System.Web.SessionState;

namespace OAFrameWork
{
  public class CSession
  {
      public static object Get(string Key)
    {
      return HttpContext.Current.Session[Key];
    }


  public static string GetString(string Key)
    {
      object obj = HttpContext.Current.Session[Key];
      if (obj == null) return "";
      else return obj.ToString();
    }


    public static object Get(string Key,object DefaultValue)
    {
      if (HttpContext.Current.Session[Key] == null)

        return DefaultValue;
      else
        return HttpContext.Current.Session[Key];

    }


    public static object Get(string Key, object DefaultValue,Boolean CanAdd)
    {
      if (HttpContext.Current.Session[Key] == null)
      {
        if(CanAdd==true)
          HttpContext.Current.Session.Add(Key, DefaultValue);

        return DefaultValue;
      }
      else
        return HttpContext.Current.Session[Key];

    }


    public static Boolean Set(string Key,object Value)
    {
      try
      {
        if (Value == null && HttpContext.Current.Session[Key] != null)
        {
          HttpContext.Current.Session.Remove(Key);
        }
        else if (HttpContext.Current.Session[Key] == null)
          {
            HttpContext.Current.Session.Add(Key, Value);
          }
          else
          {
            HttpContext.Current.Session[Key] = Value;
          }

        return true;
      }
      catch (Exception ex)
      {
        CMsgBox.Show(ex.Message); 
        return false;
      }

    }
 

      
    
  }
}

清除Session:

Session.Abandon();//清除全部Session
//清除某個Session
Session["UserName"] = null;
Session.Remove("UserName");

網(wǎng)頁制作CMS教程網(wǎng)絡(luò)編程軟件編程腳本語言數(shù)據(jù)庫服務(wù)器

如果侵犯了您的權(quán)利,請與我們聯(lián)系,我們將在24小時內(nèi)進(jìn)行處理、任何非本站因素導(dǎo)致的法律后果,本站均不負(fù)任何責(zé)任。

聯(lián)系QQ:835971066 | 郵箱:835971066#qq.com(#換成@)

Copyright © 2002-2020 腳本教程網(wǎng) 版權(quán)所有