禁用mvc中的浏览器“保存密码”功能 [英] disable browser 'save password' functionality in mvc

查看:74
本文介绍了禁用mvc中的浏览器“保存密码”功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我们如何禁用mvc中的浏览器保存密码功能,我们使用以下代码,但不工作

Hi,

How could we disable browser 'save password' functionality in mvc,We used the following code,But not working

@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 =输入密码})



还放了一些jquery代码,但对我没有帮助



@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

$(document).ready(function () {

 

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





谢谢,

Soumya



Thank you,
Soumya

推荐答案

(document).ready(function(){
(document).ready(function () {


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





谢谢,

Soumya



Thank you,
Soumya


否 - 您无法使用ASP.NET MVC框架删除浏览器的任何功能,因为MVC能够为您提供在服务器上创建应用程序的工具,而在客户端,您可以使用客户端语言和工具来操作您自己的应用程序。浏览器软件是一个包(由您的网络应用程序无法控制的其他公司。



虽然,可能有许多其他技巧使用您可以欺骗浏览器,例如更改您要创建的输入字段的名称,或者尝试仅询问密码,而不必询问用户他的电子邮件或用户名,这样浏览器赢了不知道从记录的信息中显示哪些细节或哪些信息。但是 - 就像它一样 - 你无法控制应用程序的浏览器行为,虽然autocomplete =off可能有助于强制浏览器不保存以前在表单中成功的尝试,但保存密码功能是与浏览器相关的功能,每个浏览器都有自己的实现(它不是每个浏览器共享或遵循的标准)。
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).


这篇关于禁用mvc中的浏览器“保存密码”功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆