LoginName does not display and Loginstatus automatically change to Login after user login (Asp.net) -


i have created 3 folders manage users in asp.net , created 3 roles name of officer, user , admin.now based on following code user can redirect specific page, problem can't see username after login added using loginname , loginstatus automatically change logout login. seems user did not log in , asking log in again. (funny problem.....)

protected void login1_authenticate(object sender, authenticateeventargs e) {     if (membership.validateuser(login1.username, login1.password))     {         //perform setting cookie information          e.authenticated = true;         if (roles.isuserinrole(login1.username, "r_admin"))         {             response.redirect("admin/default.aspx");         }          if (roles.isuserinrole(login1.username, "r_officer"))         {             response.redirect("~/officer/default.aspx");         }         if (roles.isuserinrole(login1.username, "r_user"))         {             response.redirect("~/user/default.aspx");         }       } 

try moving response.redirect instructions loggedin event, instead of authenticate event.

on login control add loggedin event this:

  <asp:login id="login1" runat="server" onloggedin="login1_onloggedin"></asp:login> 

and in code behind:

protecetd void login1_onloggedin(object sender, eventargs e) {      if (roles.isuserinrole(login1.username, "r_admin"))     {         response.redirect("admin/default.aspx");     }      if (roles.isuserinrole(login1.username, "r_officer"))     {         response.redirect("~/officer/default.aspx");     }     if (roles.isuserinrole(login1.username, "r_user"))     {         response.redirect("~/user/default.aspx");     } } 

http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.login.loggedin.aspx


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -