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

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


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


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.


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