Easy login method for DNN based web sites


/ Published in: C#
Save to your folder(s)

Just a quick down and dirty login function I use.


Copy this code and paste it in your HTML
  1. public void LogIn(object sender, EventArgs e)
  2. {
  3. //do login
  4. UserLoginStatus loginStatus = UserLoginStatus.LOGIN_FAILURE;
  5. UserInfo objUserInfo = UserController.ValidateUser(0, txtUser.Text,txtPassword.Text, "DNN", "", PortalSettings.PortalName, this.Request.UserHostAddress, ref loginStatus);
  6. if (loginStatus == UserLoginStatus.LOGIN_SUCCESS || loginStatus == UserLoginStatus.LOGIN_SUPERUSER)
  7. {
  8. bool isPersistent = false;
  9.  
  10. //User login
  11. UserController.UserLogin(0, objUserInfo, PortalSettings.PortalName, this.Request.UserHostAddress, isPersistent);
  12. Response.Redirect("/");
  13. }
  14. else
  15. {
  16. //show fail...
  17. errorBox.Visible = true;
  18. }
  19. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.