The DNN login page is the most forgotten part in all DNN users and even some professional DNN portals. There are few modules that allow you to have a simplified login or pop up login like digg.com but you need to pay or it and it is not cheap and easy to change the design.

In order to make changes to your DNN Login page, you have to understand the components in the login module. The DNN Login module consists of 4 parts which is the DNN Membership Authentication System, The Authentication Provider, The Login Module itself and the Language Resources Files (.resx).

In this tips I am not going to explain how to create new DNN module and its settings. Instead, I will try explaining how to register a new user and login from a custom module interface by using Dotnetnuke class methods.

User Registration Interface:
For building a Custom Registration module we need to have required fields like, firstname, lastname, emailId, username and password in a form also need to add required field validation to these fields. For registering a new user we need to fill the above information to the UserInfo object present within DotNetNuke.Entities.Users namespace.

using DotNetNuke.Entities.Users;
using DotNetNuke.Security.Membership;
 
                UserInfo objUser = new UserInfo();
 
                objUser.PortalID = this.PortalId;
                objUser.IsSuperUser = false;
                objUser.FirstName = txtFirstName.text;
                objUser.LastName = txtLastName.text;
                objUser.DisplayName = txtFirstName.text + " " + txtLastName.text;
                objUser.Email = txtEmail.text;
                objUser.Username = txtUserName.text;
 
               UserMembership objMembership = new UserMembership();
                objMembership.Approved = true;
                objMembership.CreatedDate = DateTime.Now;
                objMembership.Email = txtEmail.text;
                objMembership.Username = txtUserName.text;
                objMembership.Password = txtPassword.text;
                objUser.Membership = objMembership;
 
         UserCreateStatus result = UserController.CreateUser(ref objUser);

                if (result == UserCreateStatus.Success)
                {
                    Response.Write("user registered successfully");
                }
 

Custom User login Interface:
We need to have Username, Password text field and a Login Button in a Form.
 
- UserController class having ValidateUser method to validate user:
UserInfo UserController.ValidateUser(int portalId, string Username, string Password, string authType, string Verificationcode, string Portalname, string IP, ref UserLoginStatus loginStatus) UserLoginStatus object is used to check the status of User before login.
 
- UserController class also having UserLogin method using which we can login into website through programming from our custom module:
void UserController.UserLogin(int portalId, UserInfo user, string portalName, string IP, bool CreatePersistent)
CreatePersistent is used to remember the password after login
 
  protected void btnSignin_Click(object sender, ImageClickEventArgs e)
        {
                UserLoginStatus loginStatus = UserLoginStatus.LOGIN_FAILURE;
                
                UserInfo objUserInfo = UserController.ValidateUser(this.PortalId, txtUserName.text,
                txtPassword.text, "DNN", "", PortalSettings.PortalName, this.Request.UserHostAddress, ref loginStatus);
           
                if (loginStatus == UserLoginStatus.LOGIN_SUCCESS || loginStatus == UserLoginStatus.LOGIN_SUPERUSER)
                {
                    bool isPersistent = false;

                    UserController.UserLogin(this.PortalId, objUserInfo, PortalSettings.PortalName, this.Request.UserHostAddress, isPersistent);
                    this.Response.Write("Login success");
 
                }
                else
                {
                    this.Response.Write("Login failure");
                }
        }


Need DotNetNuke cloud hosting? Please visit our site at http://www.asphostportal.com. Just with only $4.00/month to get DotNetNUke cloud hosting. If you have any further questions, please feel free to email us at [email protected].

ASPHostPortal.com, Microsoft No#1 Recommended Spotlight Hosting Partner, is now providing this FREE DOMAIN and DOUBLE SQL Space promotion link for new clients to enjoy the company's outstanding web hosting service.