2017-04-17 105 views
2

如何防止我的用户名和密码即使Google Smart Lock已将其保存,Chrome中的ASP.NET/C# TextBox字段也不会预填充。如何关闭自动填充功能并防止预填充字段

我可以进入Google设置并将其删除,但下次登录时,系统会再次提示保存此网站的密码。出现提示时,我无法阻止本网站上的其他用户保存密码。

我知道有很多这个类似的问题,但没有人似乎为我工作。我曾尝试(其中包括):

  1. 在我的文本框
  2. 在我的文本框设置AutoCompleteType = “已禁用” 属性设置自动完成= “关闭” 属性
  3. 此:https://stackoverflow.com/a/36904814/4241820

我银行网站可以防止密码被保存或预先填写。这是如何完成的?

UPDATE:这是从我的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> 

回答

1

我们得到了这样相同的情况,但我也跟着以下的方法来克服这种情况

在里面的新页面您标记之前,您txtInsuredPassword尽量保持这种输入类型,以便您的问题将得到解决

<input style="display: none" type="text" name="fakeusername" /> 
    <input style="display: none" type="password" name="fakepassword" /> 

尽量保持上述实际的用户名这个MARUP和密码

+0

感谢您的建议。我尝试过,但预填的用户名和密码仍然出现。 – Windhoek

+0

@Windhoek你可以分享你的代码吗? – Webruster

+0

这就是: “


” – Windhoek

2

请勿在文本框中设置autocomplete="off",而应在放置它的表单上设置autocomplete="off"

<form id="form1" runat="server" autocomplete="off">

+1

这个解决方案可以工作。 –

+0

感谢您的回复。我在master页面(包含文本框)的“表单”中添加了autocomplete =“off”。但是当我加载页面时,预填的用户名仍然出现。 – Windhoek

+0

@Windhoek我不知道为什么它仍然出现,但一个建议,不要使用相同的母版页登录和其他网页。如果您在母版页中使用身份验证相关的东西作为常见的跨应用程序,那么这很有帮助。 – Imad