session

using System.Web;

namespace RM.Common.DotNetBean
{
    public class RequestSession
    {
        private static string SESSION_USER = "SESSION_USER";
        private static string SESSION_COMPANY = "SESSION_COMPANY";

        public static void AddSessionUser(SessionUser user)
        {
            HttpContext rq = HttpContext.Current;
            rq.Session[RequestSession.SESSION_USER] = user;
        }
            

        public static SessionUser GetSessionUser()
        {
            HttpContext rq = HttpContext.Current;
            return (SessionUser)rq.Session[RequestSession.SESSION_USER];
        }
        public static void AddSessionCompany(SessionCompany company)
        {
            HttpContext rq = HttpContext.Current;
            rq.Session[RequestSession.SESSION_COMPANY] = company;
        }
        public static SessionCompany GetSessionCompany()
        {
            HttpContext rq = HttpContext.Current;
            return (SessionCompany)rq.Session[RequestSession.SESSION_COMPANY];
        }
    }
}

调用方法

 model.companyid = RequestSession.GetSessionCompany().CompanyId.ToString();

posted @ 2015-04-20 13:29  fleam  阅读(213)  评论(0编辑  收藏  举报