2012-07-15 120 views
-1

在dotNet MVC應用程序中,我想知道如何檢查用戶是否已經登錄。
我想在登錄後立即將登錄用戶重定向到已認證的索引頁面,而不是主頁控制器中的索引頁面。檢查用戶是否登錄

回答

0
public ActionResult LogOn(LogOnModel Model) 
{ 
    if (User.Identity.IsAuthenticated) 
    { 
     return RedirectToAction(...); 
    } 

    .. login logic 

    return View(Model); 
} 

請注意,您也可以在web.config中使用表單身份驗證來執行此操作。