C#中沒有session 可以自己寫方法
using System;
using System.Collections.Generic;
using System.Text;
namespace JXC69IC
{
class SingletonTemplate<T>
{
private static object locker = new object();
private static SingletonTemplate<T> obj = null;
private static T instance = default(T);
private SingletonTemplate()
{
instance = Activator.CreateInstance<T>();
}
public static T Instance
{
get
{
lock (locker)
{
if (obj == null)
{
obj = new SingletonTemplate<T>();
}
}
return instance;
}
}
}
}
首先初始化數據
//全局保存用戶信息
SingletonTemplate<Models.JxcCuser>.Instance.USERNAME=jc.USERNAME ;//用戶名
SingletonTemplate<Models.JxcCuser>.Instance.USERFT=jc.USERFT;//密碼
SingletonTemplate<Models.JxcCuser>.Instance.USERPWD=jc.USERPWD;//權限
調用獲取數據
//獲取用戶權限信息
string userft = SingletonTemplate<Models.JxcCuser>.Instance.USERFT.ToString();
string username = SingletonTemplate<Models.JxcCuser>.Instance.USERNAME.ToString();
ok其中的單例模式 就不多說了