0

I have a users page that contains a table of users. In that page I have a form that creates users. When submit button of that form is clicked Register Action is called in AccountController. And register action redirects to users page again to show all users with newly added user.

The problem is that; although i dont make the user log in, browser asks me to remember the password for the user i have created. I dont want it show me that remember password popup

Here is my Register Action

    [HttpPost]
    public ActionResult Register(User user, int page)
    {
        if (ModelState.IsValid)
        {
            if (user.Id == 0)
            {
                user.Password = HashPassword(user.Password);
                context.Users.Add(user);
                //context.Entry(user.Role).State = System.Data.Entity.EntityState.Unchanged;
                context.SaveChanges();
            }
            else
            {
                //user.Email = (from dbUser in context.Users where dbUser.Id == user.Id select dbUser.Email).FirstOrDefault();
                user.Password = HashPassword(user.Password);
                context.Entry(user).State = System.Data.Entity.EntityState.Modified;
                context.SaveChanges();
            }
        }
        if (page == 0)
        {
            return RedirectToAction("Users", "Dashboard");
        }
        else
        {
            return RedirectToAction("Users", "Dashboard", new { page });
        }
    }

This is Users Action of my DashboardController

    [Authorize(Roles = "Admin")]
    public ActionResult Users(int page = 1)
    {
        ViewBag.Users = (from user in context.Users join company in context.Companies on user.CompanyID equals company.ID into joined from j in joined.DefaultIfEmpty() select user).OrderBy(a => a.Id).ToPagedList(page, 15);
        List<Role> vRoles = (from role in context.Roles select role).ToList();
        ViewBag.Roles = new SelectList(vRoles, "ID", "Authority");
        List<Company> vCompanies = (from company in context.Companies select company).ToList();
        ViewBag.Companies = new SelectList(vCompanies, "ID", "CompanyName");
        return View();
    }

My users page is restricted to Access via Authorize annotation

MOD
  • 1,010
  • 3
  • 18
  • 39
  • see if this answer can help: http://stackoverflow.com/questions/32369/disable-browser-save-password-functionality – rogerdeuce Apr 08 '15 at 15:10
  • I dont want to ignore it. It already should not have appeared – MOD Apr 08 '15 at 15:15
  • I may be wrong (I've never tried to do this) but I think putting that 'autocomplete = off' just prevents the browser from offering to store the password. – rogerdeuce Apr 08 '15 at 15:18
  • 1
    @rogerdeuce that doesn't work in chrome –  Apr 08 '15 at 16:26
  • 1
    You can change the register `@Html.PasswordFor` to `@Html.TextboxFor` and add your own masking. The browser picks up on the password field .. thats what is opening the popup –  Apr 08 '15 at 16:31

0 Answers0