我使用的是ASP.NET身份会员资格。这是Startup.Auth.cs代码:
app.CreatePerOwinContext(EFDbContext.Create);
app.CreatePerOwinContext<ApplicationUserManager>(ApplicationUserManager.Create);
app.CreatePerOwinContext<ApplicationSignInManager>(ApplicationSignInManager.Create);
// Enable the application to use a cookie to store information for the signed in user
// and to use a cookie to temporarily store information about a user logging in with a third party login provider
// Configure the sign in cookie
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
LoginPath = new PathString("/Account/Login"),
ExpireTimeSpan = TimeSpan.FromHours(3),
CookieName = "MyLoginCookie",
Provider = new CookieAuthenticationProvider
{
// Enables the application to validate the security stamp when the user logs in.
// This is a security feature which is used when you change a password or add an external login to your account.
OnValidateIdentity = SecurityStampValidator.OnValidateIdentity<ApplicationUserManager, User>(
validateInterval: TimeSpan.FromMinutes(30),
regenerateIdentity: (manager, user) => user.GenerateUserIdentityAsync(manager))
}
});
正如您所看到的,我已将expiretimespan
设置为3小时,但在生产服务器上它不起作用;它在大约十分钟后到期。当我检查元素MyLoginCookie仍然存在时。在localhost上它工作正常。为什么生产服务器上有问题?我需要设置CookieDomain吗?
答案 0 :(得分:8)
用户注销的原因是表单身份验证数据和视图状态数据的验证错误。它可能由于各种原因而发生,包括在托管服务中使用Web场。您应该检查项目void setup () {
frameRate(10);
stroke(255, 255, 255);
noFill();
rect(100,155,300,300);
size(500, 500);
}
void square () {
for (int x = 100; x <= 300; x += 100) {
for (int y = 155; y <= 355; y += 100) {
fill(random(0, 255), random(0, 255), random(0, 255));
rect(x, y,100,100);
}
}
};
void draw () {
int time = 0;
int logoLength = 100;
if (time < logoLength) {
fill(255, 255, 255);
background(0, 0, 0);
textFont(createFont("Lucida console", 19));
textAlign(CENTER,CENTER);
text("Ghost Cube Games presents",250,59);
time++;
print(time);
square();
} else if (time == logoLength) {
background(255, 255, 255);
}
}
中的<machineKey>
。检查here以获取相关详细信息。如果您的webconfig
中没有<machineKey>
,请尝试在您的网络配置中webconfig
之后添加这段代码:
<system.web>
另一个选项是在webconfig中使用生成的ASP.NET Machine Key。我推荐的一些在线工具是this和this。