How to prevent Google Chrome from saving passwords in ASP.NET MVC?

12,692

Solution 1

Try autocomplete='off' on the input field. Browsers should respect this - but of course they don't have to.

UPDATE: This is now part of HTML5, and according to that standard you can add autocomplete='off' to the form tag to have it apply to all fields within the form.

http://www.w3schools.com/html/html5_form_attributes.asp

Solution 2

I guess you are asking about programmatic way of preventing the save password dialog and not by using the configurable options available at the browser (if you are looking for configurable options this link may help Google Chrome Manage Password).

Now coming to programmatic way, there are many ways to do it. Lets say you have a password field with name pass:

<input type="password" name="pass">

You have to add couple of additional dummy password field on top of the original password field (which in our case name="pass").

Those additional dummy password field should not be visible to users so we have to control the display aspect of those dummy password field using style sheet display: none

Eg:

<input type="password" name="password_fake" id="password_fake" value="" style="display:none;" />

Note this sometimes may not work, in that case try to use other css styles to hide the elements from the users.

Hide elements via CSS

Let me know if it helps.

Solution 3

When the user clicks "submit", take the password from the form field, put it in a hidden input and send the form.

Solution 4

For chrome - and other browsers that don't respect autocomplete="off" - you can use autoCompleteType="disable" or x-autoCompleteType="disable"

Share:
12,692
ChrisP
Author by

ChrisP

Updated on July 22, 2022

Comments

  • ChrisP
    ChrisP almost 2 years

    Is there a way to prevent Google Chrome and other browsers from saving a password for a specific site? The server is ASP.NET MVC .NET4.

  • Pauli Østerø
    Pauli Østerø over 13 years
    hehe, nice hack... never though of that :)
  • Zeeshan
    Zeeshan over 8 years
    it works. can somebody explain, how is this possible?