public ActionResult Register(RegisterModel model)
        {
            if (ModelState.IsValid)
            {
                // Attempt to register the user
                a.MembershipCreateStatus createStatus;
                a.Membership.CreateUser(model.UserName, model.Password, model.Email, passwordQuestion: null, passwordAnswer: null, isApproved: true, providerUserKey: null, status: out createStatus);

                if (createStatus == a.MembershipCreateStatus.Success)
                {
                    DataClasses1DataContext db = new DataClasses1DataContext();
                    System.Guid idUs = db.Users.Where(b => b.UserName == model.UserName).Select(b => b.UserId).ToArray()[0];
                    System.Guid idRol = db.Roles.Where(b => b.RoleName == "Usuario").Select(b => b.RoleId).ToArray()[0];
                    UsersInRole rel = new UsersInRole() { RoleId = idRol, UserId = idUs };
                    db.UsersInRoles.InsertOnSubmit(rel);
                    db.SubmitChanges();
                    a.FormsAuthentication.SetAuthCookie(model.UserName, createPersistentCookie: false);

                    usuario nuevo = new Models.usuario();
                    nuevo.id = idUs;
                    nuevo.ciudad = model.Ciudad;
                    nuevo.estado=model.Estado;
                    nuevo.pais=model.pais;
                    nuevo.nit=model.nit;
                    nuevo.telefono = model.telefono;
                    nuevo.direccion=model.direccion;
                    nuevo.comentarios=model.comentarios;
                    db.usuarios.InsertOnSubmit(nuevo);
                    db.SubmitChanges();
                    return RedirectToAction("Index", "Home");
                }
                else
                {
                    ModelState.AddModelError("", ErrorCodeToString(createStatus));
                }
            }

            // If we got this far, something failed, redisplay form
            return View(model);
        }
        public ActionResult Register(RegisterModel model)
        {
            if (ModelState.IsValid)
            {
                // Attempt to register the user
                try
                {
                    WebSecurity.CreateUserAndAccount(model.UserName, model.Password);
                    WebSecurity.Login(model.UserName, model.Password);
                    return RedirectToAction("Index", "Home");
                }
                catch (MembershipCreateUserException e)
                {
                    ModelState.AddModelError("", ErrorCodeToString(e.StatusCode));
                }
            }

            // If we got this far, something failed, redisplay form
            return View(model);
        }