当前位置: 首页>>代码示例>>C#>>正文


C# HttpSessionStateBase.Add方法代码示例

本文整理汇总了C#中System.Web.HttpSessionStateBase.Add方法的典型用法代码示例。如果您正苦于以下问题:C# HttpSessionStateBase.Add方法的具体用法?C# HttpSessionStateBase.Add怎么用?C# HttpSessionStateBase.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Web.HttpSessionStateBase的用法示例。


在下文中一共展示了HttpSessionStateBase.Add方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: InvalidPasswordAttempts

        public static int InvalidPasswordAttempts(HttpSessionStateBase session, int increment = 0)
        {
            if (session == null)
            {
                return 0;
            }

            int retVal = 0;

            if (session["InvalidPasswordAttempts"] == null)
            {
                retVal = retVal + increment;
                session.Add("InvalidPasswordAttempts", retVal);
            }
            else
            {
                retVal = Conversion.TryCastInteger(session["InvalidPasswordAttempts"]) + increment;
                session["InvalidPasswordAttempts"] = retVal;
            }

            if (increment > 0)
            {
                Log.Warning("{Count} Invalid attempt to sign in from {Host}/{IP} using {Browser}.", retVal,
                    GetUserHostAddress(), GetUserIpAddress(), GetBrowser().Browsers);
            }

            return retVal;
        }
开发者ID:JonathanValle,项目名称:mixerp,代码行数:28,代码来源:PageUtility.cs

示例2: SignIn

        public void SignIn(AdminUser adminUser, HttpSessionStateBase session)
        {
            if (adminUser == null)
            {
                throw new ArgumentNullException("Invalid authentication");
            }

            formsAuthentication.SetAuthCookie(adminUser.Name, false);
            session.Add("adminUser", adminUser);
        }
开发者ID:RezaMahmood,项目名称:ChopShop,代码行数:10,代码来源:AdminAuthenticationService.cs

示例3: CreateOrUpdateKey

        private void CreateOrUpdateKey(HttpSessionStateBase session) {
            var data = session[EncryptFieldData] as Tuple<byte[], byte[]>;

            if (data == null) {
                provider.GenerateKey();
                provider.GenerateIV();
                data = new Tuple<byte[], byte[]>(provider.Key, provider.IV);
                session.Add(EncryptFieldData, data);
            }

            key = data.Item1;
            iv = data.Item2;
        }
开发者ID:priaonehaha,项目名称:NakedObjectsFramework,代码行数:13,代码来源:SimpleEncryptDecrypt.cs

示例4: IsAuthorized

        private bool IsAuthorized(HttpSessionStateBase session, HttpRequestBase request, RouteValueDictionary routeDataValues)
        {
            iisTraceListener.WriteLine("IsAuthorized");
            iisTraceListener.Flush();

            bool isAuthorized = false;

            if (routeDataValues["schoolId"] == null)
            { return false; }

            string schoolIdString = routeDataValues["schoolId"] as string;
            schoolIdString = schoolIdString.Trim().ToLower();

            if ((schoolIdString == "dashboard") || (schoolIdString == "error") || (schoolIdString == "login.aspx"))
            { return true; }

            int schoolIdInt = 0;

            if (!int.TryParse(schoolIdString, out schoolIdInt))
            { return false; }

            if (schoolIdInt == 0)
            { return false; }

            User user = session["USER"] as User;

            if (user.Schools == null)
            { user.Schools = UserAuthentication.GetSchools(user.Email); }

            foreach (School school in user.Schools)
            {
                if (schoolIdInt == school.SchoolId)
                {
                    isAuthorized = true;
                    break;
                }
            }

            user.AdminPeriods = UserAuthentication.GetAdminPeriodsBySchoolId(schoolIdInt);

            if (session["ADMINPERIOD"] == null)
            { session.Add("ADMINPERIOD", user.AdminPeriods.First()); }

            if (request.QueryString["adminPeriodId"] != null)
            {
                string adminPeriodIdString = request.QueryString["adminPeriodId"] as string;
                adminPeriodIdString = adminPeriodIdString.Trim();

                int adminPeriodIdInt = 0;

                if (int.TryParse(adminPeriodIdString, out adminPeriodIdInt))
                {
                    if (adminPeriodIdInt != 0)
                    {
                        foreach (AdminPeriod adminPeriod in user.AdminPeriods)
                        {
                            if (adminPeriodIdInt == adminPeriod.AdminPeriodId)
                            {
                                session.Add("ADMINPERIOD", adminPeriod);
                                break;
                            }
                        }
                    }
                }
            }

            return isAuthorized;
        }
开发者ID:timothyallyndrake,项目名称:portfolio,代码行数:68,代码来源:BaseReportController.cs

示例5: ForSession

 /// <summary>
 /// Gets the SessionInfo for the specified session
 /// </summary>
 public static SessionInfo ForSession(HttpSessionStateBase session)
 {
     var sessionInfo = session[SessionKey] as SessionInfo;
     if (sessionInfo == null)
     {
         sessionInfo = new SessionInfo();
         session.Add(SessionKey, sessionInfo);
     }
     return sessionInfo;
 }
开发者ID:upeo,项目名称:inbloom-dotnet,代码行数:13,代码来源:SessionInfo.cs

示例6: Add

 /// <summary>
 /// Add
 /// </summary>
 /// <param name="context"></param>
 /// <param name="sessionState"></param>
 public static void Add(HttpSessionStateBase sessionState, string sessionKey, object value)
 {
     sessionState.Add(sessionKey, value);
 }
开发者ID:vuchannguyen,项目名称:lg-py,代码行数:9,代码来源:SessionManager.cs

示例7: IsReadyToPost

        /// <summary>
        /// Determines whether this instance is ready to post the specified message now.
        /// </summary>
        /// <returns><c>true</c> if this instance is ready to post the specified session when; otherwise, <c>false</c>.</returns>
        /// <param name="session">User session.</param>
        /// <param name="when">Time code of post.</param>
        private static bool IsReadyToPost(HttpSessionStateBase session, string when)
        {
            if (session == null || string.IsNullOrWhiteSpace(when))
                        {
                                return true;
                        }

                        if (session["Start"] == null)
                        {
                                session.Add("Start", HomeController.FindTime(when));
                                Console.WriteLine("Set -Start- to " + session["Start"].ToString());
                        }

                        var start = (DateTime)session["Start"];
                        var wait = HomeController.Elapsed(start, when);
                        var real = DateTime.Now - (DateTime)session["RealStart"];
                        return real >= wait;
        }
开发者ID:jcolag,项目名称:HollowHolla,代码行数:24,代码来源:HomeController.cs


注:本文中的System.Web.HttpSessionStateBase.Add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。