2012-06-06 4 views
0

사용자가 인증되었는지 확인하고 사용자가 인증되지 않은 경우 다른보기로 전달해야합니다.C# mvc3 다른보기로드

public ActionResult UserMaintenance() 
{ 

    if (User.Identity.IsAuthenticated) 
    { 
    return View(); 
    } 
    else 
    { 
    LogOn.View; //// this is the area that needs help 
    } 
} 
나는 로그인과 암호를 입력하도록 사용자에게보기를 제시 하 고 싶습니다

....

답변

2

RedirectToAction을 컨트롤러의 모든 동작에 사용할 수 있습니다. 당신은 ASP.net MVC를 사용하는 것처럼

return RedirectToAction("Action", "Controller"); 

당신은 Account 컨트롤러 LogOn 행동에 리디렉션 할 수 있습니다

public ActionResult UserMaintenance() 
{ 

    if (User.Identity.IsAuthenticated) 
    { 
    return View(); 
    } 
    else 
    { 
    return RedirectToAction("LogOn", "Account"); 
    } 
}