I am developing an ASP.Net MVC 3 application using C# and SQL Server 2005. I am using Entity Framework with a code-first approach.

I have an interface for the LOG ON (connection) which is related to my base where I have a USER table (contain Login + password).

This is the View of connexion :LogonPartial.acx (partial view that strongly typed from the UserViewModel) 

```
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<MvcApplication2.ViewModels.UserViewModel>" %>

<%
    if (Request.IsAuthenticated) {
%>

        Welcome <strong><%: Page.User.Identity.Name %></strong>!
        [ <%: Html.ActionLink("Log Off", "LogOff", "Account") %> ]
<%
    }
    else {
%> 
        [ <%: Html.ActionLink("Log On", "LogOn", "Account") %> ]
<%
    }
%>

```

When the connexion success : I have only the 'Log On' link.
When the connexion fails : the page is empty

This is the Controller :

```
[ChildActionOnly]
        public ActionResult LogedInUser()
        {
            var user = new UserViewModel();
            if (Request.IsAuthenticated)
            {
                user.Nom_User = User.Identity.Name;
            }
            return PartialView(user);
        }
private GammeContext db = new GammeContext();
        [AcceptVerbs(HttpVerbs.Post)]
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1054:UriParametersShouldNotBeStrings",
            Justification = "Needs to take same parameter type as Controller.Redirect()")]
        public ActionResult LogedInUser(string Matricule, string passWord, bool rememberMe, string returnUrl)
        {
            if (!ValidateLogOn(Matricule, passWord))
            {
                return Connection(Matricule, passWord, returnUrl);
            }

            //FormsAuth.SignIn(Matricule, rememberMe);

            if (!String.IsNullOrEmpty(returnUrl))
            {
                return Redirect(returnUrl);
            }
            else
            {
                return RedirectToAction("Index", "Home");
            }
        }

        public ActionResult Connection(string Matricule, string passWord, string returnUrl)
        {
            List<User> users = db.Users.ToList();
            ActionResult output = null;

            if (users.Any())
            {
                foreach (User u in users)
                {
                    if ((u.Matricule == Matricule) && (u.passWord == passWord))
                    {
                        output = View();
                    }
                }
            }
            else
            {
                output = Redirect(returnUrl);
            }

            return output;
        }

```