我有以下代码来授权用户
system("make")
这就是我bool isValidUser = AccountService.IsValidUser(username, password, out message);
if (isValidUser)
{
var user = new UserDTO {Username = username, Password = password};
SetAuthCookie(username, true, user);
Response.Redirect(App_GlobalResources.Urls.Position, true);
}
protected void SetAuthCookie(string name, bool rememberMe, IUserDTO userData)
{
// In order to pickup the settings from config, we create a default cookie and use its values to create a new one.
var cookie = FormsAuthentication.GetAuthCookie(name, rememberMe);
var ticket = FormsAuthentication.Decrypt(cookie.Value);
var userJson = JsonConvert.SerializeObject(userData);
var newTicket = new FormsAuthenticationTicket(ticket.Version, ticket.Name, ticket.IssueDate, ticket.Expiration,
ticket.IsPersistent, userJson, ticket.CookiePath);
var encTicket = FormsAuthentication.Encrypt(newTicket);
// Use existing cookie. Could create new one but would have to copy settings over...
cookie.Value = encTicket;
Response.Cookies.Add(cookie);
}
的样子
web.config
当我在IE上使用该应用程序时,会创建<authentication mode="Forms">
<forms loginUrl="~/Pages/Account/Login.aspx" timeout="120" slidingExpiration="true"/>
</authentication>
<machinekey decryptionkey="mydescriptionkey,IsolateApps" validationkey="validationKey,IsolateApps" />
cookie。但是,这不会发生在.ASPXAUTH
或Chrome
上。我只是更新了项目框架,从Firefox
到4
。我不知道这是否可能导致这种情况,因为该应用曾经在这些浏览器上运行。