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();

你可能感兴趣的:(session)