如何防止在 Chrome 中预先填充我的用户名和密码 ASP.NET/C# 文本框字段,即使 Google Smart Lock 已保存它。
我可以进入 Google 设置并将其删除,但下次登录时,系统会再次提示我保存该网站的密码。我无法阻止此网站上的其他用户在出现提示时保存密码。
我知道有很多类似的问题,但似乎没有一个对我有用。我已经尝试过(除其他外):
- 在我的文本框中设置 autocomplete="off"属性
- 在我的 TextBox 中设置 AutoCompleteType="Disabled"属性
- 这个:https://stackoverflow.com/a/36904814/4241820
我的银行网站能够阻止保存或预填写密码。这是怎么做到的?
更新:这是我的 Login.aspx 页面中的代码:
<%@ Page Title="" Language="C#" MasterPageFile="./MyMasterPage.Master" AutoEventWireup="true" CodeBehind="Login.aspx.cs" Inherits="MyApp.Login" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<table style="width: 294px; margin-left: auto; margin-right: auto; margin-top: 80px; margin-bottom: auto; border: none; border-collapse: collapse;">
<tr style="background-color: #FFFFFF;">
<td style="text-align: center;">
<br />
<img src="Images/AppLogo.png" alt="Application Logo" />
</td>
</tr>
<tr>
<td style="background-color: #FFFFFF; text-align: center;">
<asp:PlaceHolder runat="server" ID="LoginStatus" Visible="false">
<p>
<asp:Label ID="lblStatus" CssClass="lblSkin" runat="server" />
</p>
</asp:PlaceHolder>
<asp:PlaceHolder runat="server" ID="LoginForm" Visible="false">
<br />
<asp:Label ID="lblTitle" CssClass="lblSkinLarge" runat="server" /><br />
<br />
<div style="margin-bottom: 10px">
<input style="display: none" type="text" name="fakeusername" />
<asp:Label Text="Username" CssClass="lblSkin" AssociatedControlID="UserName" runat="server" /><br />
<asp:TextBox runat="server" ID="UserName" Width="244px" autocomplete="off" AutoCompleteType="Disabled" />
</div>
<div style="margin-bottom: 10px">
<input style="display: none" type="password" name="fakepassword" />
<asp:Label Text="Password" AssociatedControlID="Password" CssClass="lblSkin" runat="server" /><br />
<asp:TextBox runat="server" ID="Password" TextMode="Password" Width="244px" autocomplete="off" />
</div>
<div style="margin-bottom: 10px">
<div>
<asp:ImageButton AlternateText="Login" ImageUrl="~/Images/btnLogin.jpg" OnClick="SignIn" runat="server" />
<br />
<asp:HyperLink ID="lnkForgotPassword" CssClass="lblSkin" NavigateUrl="Login_ResetPassword.aspx" Text="Forgot password" runat="server" />
</div>
</div>
</asp:PlaceHolder>
<asp:PlaceHolder runat="server" ID="LogoutButton" Visible="false">
<div>
<div>
<asp:Button runat="server" OnClick="SignOut" Text="Log out" />
</div>
</div>
</asp:PlaceHolder>
</td>
</tr>
</table>
</asp:Content>
最佳答案
不要设置autocomplete="off"
在文本框上,但在放置它的表单上。
<form id="form1" runat="server" autocomplete="off">
关于c# - 如何关闭自动完成功能并防止预填充字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43445159/