Click here to Skip to main content
15,913,232 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

How could we disable browser 'save password' functionality in mvc,We used the following code,But not working
C#
@using (Html.BeginForm(new { autocomplete = "off", id = "form1" }))
   {


@Html.PasswordFor(m => m.Password, new { @class = "input-block-level", @placeholder = "Password", @id = "txtpasswoprd",autocompletetype="Disabled", @title = "Enter your Password" })

Also put some jquery code but didn't help to me
C#
$(document).ready(function () {

 

        $('#form1').attr('autocomplete', 'off');
    }


Thank you,
Soumya
Posted
Comments
Nathan Minier 2-Feb-15 7:38am    
Short answer is: you can't. It's a browser behavior and is controlled by the user, not by individual pages.

That said, you can work around it. Assuming that you're willing to write your own AuthenticationProvider, you can use a testbox that writes to a jQuery array (and replaces the characters in the text field with *) and send that.

This is, of course, a significant security issue, and not even remotely worth avoiding the "Save this password" functionality.
Richard Deeming 2-Feb-15 15:54pm    
Why would you want to make your site LESS secure by preventing the user from using the built-in tools to manage their passwords?

If you prevent the user from saving their password in the browser, then you're forcing them to pick a password they'll be able to remember. That will almost certainly end up being the same password they've used on other sites.

You're also conditioning your users to type their password every time they see something that looks like your login page - an invitation to phishing scams.

There's a good discussion on the topic on StackExchange:
Should websites be allowed to disable autocomplete on forms or fields?[^]

1 solution

No - you cannot remove any functionality of the browser using the ASP.NET MVC framework, because MVC is capable of providing you with the tools to create the application on your server, whereas once on the client-side you can use the client-side languages and tools to manipulate your own application only. The browser software is a package (held by other company) that your web application has no control over.

Although, there can be many other tricks using which you can fool the browser, such as changing the name of the input field you're going to create, or by either trying to ask for a password only, without having to ask the user for his email or username, this way browser won't know which detail or which information to show from the recorded information. But - as it as - there is no way that you can control the behaviour of the browser for your application, although autocomplete="off" can be helpfull for forcing the browser to not save the previous successful attempts in the form, but the "Save Password" feature is a browser-related feature and every browser has its own implementation (it is not a standard that every browser shares or follows).
 
Share this answer
 
Comments
soumyaraj 3-Feb-15 7:58am    
Thank you for your suggestions.I tried to use following link.But It was not help to me.
http://stackoverflow.com/questions/24237449/remove-saved-usernames-and-passwords-of-browser-from-web-application

Could you please advise me for the following terminology

Some banks seem to use ,when we enter the password in to login section and then go to submit button,the password seems to be changed(may be GUID) and then the changed password goes to remember me section.Could you please let me know how could we implement

Many Thanks,
Soumya
Afzaal Ahmad Zeeshan 3-Feb-15 11:52am    
Password doesn't change, the password is always hashed before being stored inside the database actually, for more on this you might be interested in reading another helpful post that I wrote a few weeks ago, this article would grant you a basic knowledge of how passwords are stored.

Anyways, you cannot change the browser's own methodology, it is because the saved password is inserted into the HTML of your website once the website has been rendered and the browser makes its own sensible thinking to add the password. If you change the names of the field, or you try to ask for the password alone (with out asking for username) then you can trick the browser. There are multiple other ways of doing so, but none of them are the best and ensured ones.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900