2013-12-13 38 views
5

爲什麼本示例在使用ApplicationCookie登錄之前調用SignOut for ExternalCookie?這只是一種確保認證信息清潔的方法嗎? (完整的例子是在這裏:http://www.asp.net/identity/overview/getting-started/introduction-to-aspnet-identity爲什麼在使用ApplicationCookie和ASP.Net Identity之前調用SignOut(DefaultAuthenticationTypes.ExternalCookie)?

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); 
} 

回答

9

其基本清理,外部餅乾應該得到最終被清除,其僅需要存儲的要求從谷歌返回/ FB/Twitter的,使得應用程序可以拉任何數據它需要在簽署用戶之前。所以SignIn是清除外部數據的好地方。

+0

這就是我想要的 –

+3

上下文解釋https://stackoverflow.com/questions/26166826/usecookieauthentication-vs-useexternalsignincookie – rism

相關問題