I'm working with ASP.NET MVC 4. When we build a project, they add an `AccountController` by default. You can create an acoount and log in right away... but after they've logged in, try to type `http://localhost:port/Account/LogOn`. You still stay at the Login page with the login form. 

I have tried to redirect the user by using this code:

```
    //
    // GET: /Account/LogOn
    [AllowAnonymous]
    public ActionResult LogOn()
    {

        if(Membership.GetUser().UserName != null)
            RedirectToAction("Index", "Home");
        return ContextDependentView();
    }

```

The code works fine until I log out, and then this code no longer works. Please show me the right way to do this.