Oflocet Oflocet - 1 year ago 111
C# Question

Remove browser autocompletion in MVC

I am currently trying to remove the form autocompletion done by the user's browser which can cause some critical behavior since it fills the password field. I have already add the autocompletion attribute to all of my textbox but when i try with firefox it stills load my current login information into the fields.

Do one you find a manner to resolve this issue ?

Thanks in advance.

EDIT : Since it's not clear, i have already add the aucompletion attribute with the value set to "off".

Answer Source

There is an autocomplete=off property in html.

It is used in the top right search box on this very page, inspect the html you'll see:

<input autocomplete=​"off" name=​"q" class=​"textbox" placeholder=​"search" ..... />

See this MDN article: https://developer.mozilla.org/en/How_to_Turn_Off_Form_Autocompletion

In MVC you would implement this at the form or for a textbox like so:

    action, controller, FormMethod.Post, new {autocomplete="off"})


Html.TextBoxFor(model => model.EmployerNumber, new {autocomplete="off"})
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download