2014-05-16 45 views
1

我正在關注微軟官方的webforms教程。在本教程中,他們解釋瞭如何在用戶提供有效憑證的情況下重定向用戶,或者在用戶未登錄並嘗試訪問受保護頁面時將其重定向到登錄頁面。但是,如果用戶已經登錄了表單身份驗證票據,該用戶將如何存儲並訪問登錄頁面。如何從那裏訪問表單身份驗證票據並將用戶重定向到默認頁面?如何在用戶訪問登錄頁面時重定向用戶?

鏈接教程 http://www.asp.net/web-forms/tutorials/security/introduction/an-overview-of-forms-authentication-vb

回答

0

在登錄頁面,您是否齊全驗證,你只是他的重定向爲:

protected void Page_Load(object sender, EventArgs e) 
{ 
    if (!IsPostBack) 
    { 
     // if is already logged in 
     if (HttpContext.Current.User.Identity.IsAuthenticated) 
     { 
      // redirect to home page 
      Response.Redirect("/"); 
     } 
    }  
} 
+0

感謝您的答覆。 Request.IsAuthenticated和HttpContext.Current.User.Identity.IsAuthenticated有什麼區別? –

相關問題