本文介绍了为什么使用ApplicationCookie与ASP.Net身份之前调用SignOut(DefaultAuthenticationTypes.ExternalCookie)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么这个例子与ApplicationCookie登录前致电SignOut为ExternalCookie?这是否只是一种方法,以确保认证信息是干净的? (完整的例子是在这里:的)

 专用异步任务SignInAsync(ApplicationUser用户,布尔isPersistent)
{
    AuthenticationManager.SignOut(DefaultAuthenticationTypes.ExternalCookie);    VAR身份=等待UserManager.CreateIdentityAsync(
       用户DefaultAuthenticationTypes.ApplicationCookie);    AuthenticationManager.SignIn(
       新AuthenticationProperties(){
      IsPersistent = isPersistent
       },身份);
}


解决方案

其基本清理,外部饼干应该得到最终被清除,其只需要存储要求,从谷歌返回/ FB / Twitter的,这样应用程序可以拉什么数据是签约用户之前需要。所以,签到是一个很好的安全的地方,清除外部数据。

Why does this example call the SignOut for ExternalCookie before signing in with an ApplicationCookie? Is it just a way to make sure the authentication information is clean? (The full example is here: http://www.asp.net/identity/overview/getting-started/introduction-to-aspnet-identity)

private async Task SignInAsync(ApplicationUser user, bool isPersistent)
{
    AuthenticationManager.SignOut(DefaultAuthenticationTypes.ExternalCookie);

    var identity = await UserManager.CreateIdentityAsync(
       user, DefaultAuthenticationTypes.ApplicationCookie);

    AuthenticationManager.SignIn(
       new AuthenticationProperties() { 
      IsPersistent = isPersistent 
       }, identity);
}
解决方案

Its basically cleanup, the external cookie should get cleared eventually, its only needed to store the claims returned from google/fb/twitter etc such that app can pull whatever data it needs before signing the user. So SignIn is a good safe place to clear that external data.

这篇关于为什么使用ApplicationCookie与ASP.Net身份之前调用SignOut(DefaultAuthenticationTypes.ExternalCookie)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-29 10:37