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


C# Web.HttpSessionStateBase类代码示例

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


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

示例1: GenerateCSRFStateCode

 /// <summary>
 /// Generates the CSRF state code.
 /// </summary>
 /// <param name="pSessionState">State of the p session.</param>
 /// <exception cref="System.ApplicationException">pSessionState cannot be null</exception>
 public string GenerateCSRFStateCode(HttpSessionStateBase pSessionState)
 {
     if (pSessionState == null) throw new ApplicationException("pSessionState cannot be null");
     var statecode = Guid.NewGuid();
     pSessionState["state"] = statecode.ToString();
     return statecode.ToString();
 }
开发者ID:lazarofl,项目名称:Facebook-Easy-Access,代码行数:12,代码来源:FacebookEasyAccess.cs

示例2: Login

        /// <summary>
        ///     Attempts to login a user.
        /// </summary>
        /// <param name="session">The user's session.</param>
        /// <param name="username">The username.</param>
        /// <param name="password">The password.</param>
        /// <returns>true if login was successful, false otherwise.</returns>
        /// <exception cref="System.ArgumentNullException">Thrown when session is null.</exception>
        /// <exception cref="System.ArgumentException">Thrown when username or password is null, empty, or white space.</exception>
        public bool Login(HttpSessionStateBase session, string username, string password)
        {
            // Sanitize
            if (session == null)
            {
                throw new ArgumentNullException("session");
            }
            if (string.IsNullOrWhiteSpace(username))
            {
                throw new ArgumentException("cannot be null, empty, or white space", "username");
            }
            if (string.IsNullOrWhiteSpace(password))
            {
                throw new ArgumentException("cannot be null, empty, or white space", "password");
            }

            // Try and find the user by username and password
            var user = (User) null;
                // TODO: need a password! --> _userRepository.GetAll().FirstOrDefault(i => i.Email == username && i.Password == password);

            // If no user the login was unsuccessful
            if (user == null)
            {
                return false;
            }

            // Login was successful
            session[_sessionLoggedInKey] = user;
            return true;
        }
开发者ID:TS-Johns,项目名称:k94warriors,代码行数:39,代码来源:LoginHandler.cs

示例3: YafReadTrackCurrentUser

 /// <summary>
 /// Initializes a new instance of the <see cref="YafReadTrackCurrentUser"/> class. The yaf read track current user.
 /// </summary>
 /// <param name="yafSession">
 /// </param>
 /// <param name="boardSettings">
 /// </param>
 /// <param name="sessionState">
 /// The session State.
 /// </param>
 public YafReadTrackCurrentUser(
     IYafSession yafSession, YafBoardSettings boardSettings, HttpSessionStateBase sessionState)
 {
     this._yafSession = yafSession;
     this._boardSettings = boardSettings;
     this._sessionState = sessionState;
 }
开发者ID:mukhtiarlander,项目名称:git_demo_torit,代码行数:17,代码来源:YafReadTrackCurrentUser.cs

示例4: HttpSessionStateCache

        public HttpSessionStateCache(HttpSessionStateBase sessionState)
        {
            if (sessionState == null)
                throw new ArgumentNullException("sessionState");

            _sessionState = sessionState;
        }
开发者ID:v-kosyak,项目名称:Invoices,代码行数:7,代码来源:HttpSessionStateCache.cs

示例5: getGuestCartItem

        private topCart getGuestCartItem(titizOtoEntities db, HttpSessionStateBase httpSessionStateBase, HttpRequestBase request, HttpResponseBase response, int langId)
        {
            httpSessionStateBase["userId"] = null;

            topCart helperItem = new topCart();

            string guestGuid = "";
            if (httpSessionStateBase["guestGuid"] != null)
            {
                guestGuid = httpSessionStateBase["guestGuid"].ToString();
                if (guestGuid == "System.Web.HttpCookie" || guestGuid == "00000000-0000-0000-0000-000000000000")
                {
                    guestGuid = getGuidCookieOrNew(request, response);
                    httpSessionStateBase["guestGuid"] = guestGuid;
                }

            }
            else
            {
                guestGuid = getGuidCookieOrNew(request, response);
            }

            helperItem.guestGuid = guestGuid;

            var basketList = db.tbl_basket.Where(a => a.guestCode == guestGuid).ToList();
            if (basketList != null && basketList.Count > 0)
            {
                helperItem.basketIdString = string.Join(",", basketList.Select(a => a.basketId).ToList());
                helperItem.productCount = basketList.Sum(a => a.quantity);
            }

            return helperItem;
        }
开发者ID:erkanAslanel,项目名称:titizOto,代码行数:33,代码来源:cartSummaryBind.cs

示例6: InitializationAuthVar

        public static void InitializationAuthVar(dynamic ViewBag, HttpSessionStateBase Session)
        {
            ViewBag.IsUser = false;
            ViewBag.IsModerator = false;
            ViewBag.IsAdmin = false;

            if (Session["user"] != null)
            {
                User user = (User)Session["user"];

                foreach (Role role in user.Roles)
                {
                    if (role.Name.Equals("USER_ROLE"))
                    {
                        ViewBag.IsUser = true;
                    }

                    if (role.Name.Equals("MODERATOR_ROLE"))
                    {
                        ViewBag.IsModerator = true;
                    }

                    if (role.Name.Equals("ADMIN_ROLE"))
                    {
                        ViewBag.IsAdmin = true;
                    }
                }


            }
        }
开发者ID:AlienaAngel,项目名称:TheatreSystem,代码行数:31,代码来源:AuthorizationHelper.cs

示例7: Update

 public static void Update(HttpSessionStateBase session, MatchWord matchWord, string Word)
 {
     List<MatchWord> ModelObject = InitializeModelObject(session["Model"]);
     ModelObject.RemoveAll(x => x.Word == Word);
     UpdateModel(matchWord, ModelObject);
     session["Model"] = ModelObject;
 }
开发者ID:ampetry17,项目名称:TeddyMatch,代码行数:7,代码来源:TeddyMatchModel.cs

示例8: Logout

 public static void Logout(HttpSessionStateBase session, HttpResponseBase response)
 {
     var module = FederatedAuthentication.SessionAuthenticationModule;
     module.DeleteSessionTokenCookie();
     module.SignOut();
     session.Abandon();
 }
开发者ID:Exclr8,项目名称:CloudCore,代码行数:7,代码来源:CloudAuthentication.cs

示例9: InitializeDatabase

 public static void InitializeDatabase(HttpSessionStateBase sessionState)
 {
     //ToDo : refacture so controllers use DatabaseServices instead of SessionStateManager
     var services = ObjectFactory.GetInstance<IDatabaseServices>();
     services.SessionStateCache = new HttpSessionStateCache(sessionState);
     services.InitDatabase();
 }
开发者ID:halcwb,项目名称:GenForm,代码行数:7,代码来源:SessionStateManager.cs

示例10: ApiAuthenticate

        public static bool ApiAuthenticate(Dictionary<string, string> sessionData, HttpSessionStateBase Session, System.Web.Http.Controllers.HttpActionContext actionContext)
        {
            string code = EncrDecrAction.Encrypt(
                           EncrDecrAction.Encrypt(EncrDecrAction.Encrypt(Session["UserId"].ToString(), true), true)
                         + EncrDecrAction.Encrypt(EncrDecrAction.Encrypt(Session["UserRoleId"].ToString(), true), true)
                         + EncrDecrAction.Encrypt(EncrDecrAction.Encrypt(Session["UserName"].ToString(), true), true)
                         + EncrDecrAction.Encrypt(EncrDecrAction.Encrypt(Session["RoleName"].ToString(), true), true)
                         + EncrDecrAction.Encrypt(EncrDecrAction.Encrypt(Session["ParentRoleName"].ToString(), true), true), true);

            if (code == Session["SRES"].ToString())
            {
                UrlHelper urlHelper = new UrlHelper(HttpContext.Current.Request.RequestContext);

                var routeValueDictionary = urlHelper.RequestContext.RouteData.Values;
                string controller = routeValueDictionary["controller"].ToString();
                string action = actionContext.Request.Method.ToString();

                int argument = actionContext.Request.RequestUri.Segments.Count() - 3;

                string query = "select * from appviews where LOWER(Controller) = LOWER(@Controller) and LOWER(Action) = LOWER(@Action) and " + sessionData["RoleName"] + "= 1 and [email protected] and ControllerType='api'";
                Hashtable conditionTable = new Hashtable();
                conditionTable["Controller"] = controller;
                conditionTable["Action"] = action;
                conditionTable["Argument"] = argument;
                DBGateway aDbGateway = new DBGateway();
                DataSet aDataSet = aDbGateway.Select(query, conditionTable);
                if (aDataSet.Tables[0].Rows.Count > 0)
                {
                    return true;
                }
            }

            return false;
        }
开发者ID:atiquereza,项目名称:DigitalVaccinationApp,代码行数:34,代码来源:Authentication.cs

示例11: checkCookie

        private void checkCookie(titizOtoEntities db, HttpSessionStateBase httpSessionStateBase, HttpRequestBase request, HttpResponseBase response, DbWithController itemController)
        {
            if (httpSessionStateBase["userId"] == null && request.Cookies["userCookie"] != null && request.Cookies["userCookie"]["userHashVal"] != null && request.Cookies["userCookie"]["userHashValTwo"] != null)
            {

                var userList = db.tbl_user.Where(a => a.registerStatuId == (int)registerStatu.registered).ToList();

                tbl_user selectedUser = null;

                string userHashVal = request.Cookies["userCookie"]["userHashVal"];
                string userHashValTwo = request.Cookies["userCookie"]["userHashValTwo"];

                foreach (var item in userList)
                {
                    if (item.password.Length > 6 && userHashValTwo == item.password.Substring(0, 7) && itemController.MD5(item.email).Substring(0, 7) == userHashVal)
                    {
                        selectedUser = item;
                        break;

                    }
                }

                if (selectedUser != null)
                {
                    httpSessionStateBase["userId"] = selectedUser.userId.ToString();
                    httpSessionStateBase["userRoleId"] = selectedUser.userTypeId.ToString();
                }
                else
                {
                    response.Cookies["userCookie"].Expires = DateTime.Now.AddDays(-1);

                }

            }
        }
开发者ID:erkanAslanel,项目名称:titizOto,代码行数:35,代码来源:cartSummaryBind.cs

示例12: SetupUserSession

 /// <summary>
 /// Does a setup of the session indexes that are used by controllers to check if a Client has logged in
 /// </summary>
 /// <param name="session"></param>
 public static void SetupUserSession(HttpSessionStateBase session, string username, int roleId)
 {
     session[SESSION_USERNAME_KEY] = username;
     session[SESSION_ROLE_KEY] = (Role) roleId;
     session[SESSION_RETRY_DELAY_KEY] = null;
     session[SESSION_RETRIES_KEY] = 0;
 }
开发者ID:nissafors,项目名称:Bibblan,代码行数:11,代码来源:AccountHelper.cs

示例13: doSearch

        /// <summary>
        /// Private helper method to perform a new search or maintain a previous search through 
        /// pagination and filter changes
        /// </summary>
        /// <param name="workouts">The base workout query result</param>
        /// <param name="search">The WorkoutSearch object containing the parameters to search</param>
        /// <param name="sortBy">The passed sort string if it exists, else null</param>
        /// <param name="page">The passed page param if it exists, else null</param>
        /// <param name="session">The Session object to get or set variables from/to</param>
        /// <param name="viewBag">The viewBag object to pass the set variables back to the view with</param>
        /// <returns>The searched workouts</returns>
        public static IQueryable<workout> doSearch(IQueryable<workout> workouts, WorkoutSearch search, string sortBy, int? page, HttpSessionStateBase session, dynamic viewBag)
        {
            if (page != null || !String.IsNullOrEmpty(sortBy))
            {
                search = SessionVariableManager.setSearchFromSession(session, search);
            }
            else SessionVariableManager.setSessionFromSearch(session, search);

            if (!String.IsNullOrEmpty(search.name)) workouts = workouts.Where(w => w.name.Contains(search.name));
            if (!String.IsNullOrEmpty(search.category)) workouts = workouts.Where(w => w.category.name.Contains(search.category));
            if (!String.IsNullOrEmpty(search.username)) workouts = workouts.Where(w => w.user.username.Contains(search.username));
            if (!String.IsNullOrEmpty(search.dateAdded))
            {
                string[] dateArrayString = search.dateAdded.Split('-');
                int year = Convert.ToInt16(dateArrayString[0]);
                int month = Convert.ToInt16(dateArrayString[1]);
                int day = Convert.ToInt16(dateArrayString[2]);

                workouts = workouts.Where(w =>
                    w.created_at.Year == year &&
                    w.created_at.Month == month &&
                    w.created_at.Day == day);
            }
            return workouts;
        }
开发者ID:marinaushakova,项目名称:GoFit,代码行数:36,代码来源:WorkoutSortSearch.cs

示例14: AddRequestToSession

 public static void AddRequestToSession(byte[] req, ElmahMailSAZConfig config, HttpSessionStateBase session)
 {
     var reqs = ((List<byte[]>)session[sessionKey]);
     reqs.Add(req);
     if (config.KeepLastNRequests.HasValue && reqs.Count > config.KeepLastNRequests)
         reqs.RemoveAt(0);
 }
开发者ID:mausch,项目名称:ElmahFiddler,代码行数:7,代码来源:ElmahMailSAZTraceModule.cs

示例15: 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


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