我查看了一些有关该帖子的帖子,但我仍然无法在我的问题上找到答案。 我试图为花费更多定义时间的用户创建自动注销。例如,如果我指定30分钟的Web应用程序需要自动注销用户。
我正在使用OWIN和MVC 5,我在Startup.Auth类中的配置是:
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
LoginPath = new PathString("/Account/Login"),
CookieSecure = CookieSecureOption.SameAsRequest,
SlidingExpiration = true,
ExpireTimeSpan = new System.TimeSpan(0, 0, expireMinutes, 0, 0),
});
还有:
app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);
app.UseCookieAuthentication(new CookieAuthenticationOptions());
app.UseWsFederationAuthentication(
new WsFederationAuthenticationOptions
{
Wreply = WAADReturnURL,
Wtrealm = realm,
MetadataAddress = metadata,
});
app.UseMicrosoftAccountAuthentication(
new Microsoft.Owin.Security.MicrosoftAccount.MicrosoftAccountAuthenticationOptions()
{
ClientId = "xxxx",
ClientSecret = "xxxx",
});
app.UseYahooAuthentication(
new YahooAuthenticationOptions()
{
ConsumerKey = "xxxx",
ConsumerSecret = "xxxx",
});
app.UseLinkedInAuthentication(
new LinkedInAuthenticationOptions()
{
ClientId = "xxxx",
ClientSecret = "xxxx",
});
app.UseGoogleAuthentication(new GoogleOAuth2AuthenticationOptions()
{
ClientId = "xxxx",
ClientSecret = "xxxx",
});
app.UseFacebookAuthentication(new Microsoft.Owin.Security.Facebook.FacebookAuthenticationOptions()
{
AppId = "xxxx",
AppSecret = "xxxx",
});
我正在使用WAAD和第三方提供商,如Facebook,Linkedin ......
我的web.config也设置了以下配置:
<authentication mode="None">
</authentication>
我也审查了以下帖子,但没有解决方案: MVC 5 Identity Automatic Logout
由于
答案 0 :(得分:1)
在您的Startup.Auth.cs
课程集SlidingExpiration
至false
。如果设置为true
,Identity auto会在指定TimeSpan的后半部分创建新的应用程序Cookie,并且用户会自动登录。