本文整理汇总了C#中UserIdentity.SerializeProperties方法的典型用法代码示例。如果您正苦于以下问题:C# UserIdentity.SerializeProperties方法的具体用法?C# UserIdentity.SerializeProperties怎么用?C# UserIdentity.SerializeProperties使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UserIdentity
的用法示例。
在下文中一共展示了UserIdentity.SerializeProperties方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateFormsAuthenticationTicket
public bool CreateFormsAuthenticationTicket(string loginName, AuthenticateUserResponse response)
{
// If we got here, we are authorized. Let's attempt to get the identity.
var identity = new UserIdentity
{
FirstName = response.FirstName,
LastName = response.LastName,
LoginName = loginName
};
// Create the ticket
FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(
1,
GlobalSettings.Exigo.Api.CompanyKey + "_" + loginName,
DateTime.Now,
DateTime.Now.AddMinutes(GlobalSettings.Backoffices.SessionTimeout),
false,
identity.SerializeProperties());
// Encrypt the ticket
string encTicket = FormsAuthentication.Encrypt(ticket);
// Create the cookie.
HttpCookie cookie = HttpContext.Current.Request.Cookies[FormsAuthentication.FormsCookieName]; //saved user
if (cookie == null)
{
HttpContext.Current.Response.Cookies.Add(new HttpCookie(FormsAuthentication.FormsCookieName, encTicket));
}
else
{
cookie.Value = encTicket;
HttpContext.Current.Response.Cookies.Set(cookie);
}
return true;
}