c# - Partial View with empty page ASP MVC 3 -


i developing asp.net mvc 3 application using c# , sql server 2005. using entity framework code-first approach.

i have interface log on (connection) related base have user table (contain login + password).

this view of connexion :logonpartial.acx (partial view typed 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 connexion success : have 'log on' link. when connexion fails : page empty

this 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 take same parameter type 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;         } 

i don't see you're authenticating user ? if try this:

if (!validatelogon(matricule, password)) {           return connection(matricule, password, returnurl); }  // user valid, authenticate formsauthentication.setauthcookie(matricule, true); 

Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -