本文整理汇总了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;
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}