Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# asp.net中的密码恢复SMTP服务器需要安全连接,或者客户端未通过身份验证_C#_Asp.net_Email_Authentication - Fatal编程技术网

C# asp.net中的密码恢复SMTP服务器需要安全连接,或者客户端未通过身份验证

C# asp.net中的密码恢复SMTP服务器需要安全连接,或者客户端未通过身份验证,c#,asp.net,email,authentication,C#,Asp.net,Email,Authentication,我使用默认asp.net成员身份登录用户,注册系统。我将在我的web应用程序中实现密码恢复选项。我在家里开发我的应用程序,并使用默认的本地主机服务器 我制作了一个RecoverPassword.aspx页面,下面是它的代码: <%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="RecoverPassword.aspx.cs" Inherit

我使用默认asp.net成员身份登录用户,注册系统。我将在我的web应用程序中实现密码恢复选项。我在家里开发我的应用程序,并使用默认的本地主机服务器

我制作了一个RecoverPassword.aspx页面,下面是它的代码:

    <%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="RecoverPassword.aspx.cs" Inherits="myshop.Account.RecoverPassword" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <asp:PasswordRecovery ID="RecoverPwd" runat="server"></asp:PasswordRecovery>
</asp:Content>

然后编辑我的web.config文件,代码如下:

<system.net> 
  <mailSettings> 
    <smtp deliveryMethod="Network" from="mymail@gmail.com">
       <network
          host="smtp.gmail.com"
          port="587"  
          enableSsl="true"
          password="mypassword"
          userName="mymail@gmail.com"
          defaultCredentials="true"/> 
    </smtp> 
</mailSettings>
</system.net>

保存后,当我运行PasswordRecover.aspx页面,在文本框中输入用户名并点击submit按钮时,出现以下错误

SMTP服务器需要安全连接,或者客户端未通过身份验证。服务器响应为:需要5.5.1身份验证

我不知道问题出在哪里我的gmail帐户上没有收到任何电子邮件请帮助

您可以尝试在代码中将“enable ssl”属性设置为true

smtpClient.EnableSsl = true;

在何处启用此属性?在web.config文件中,我已经将其启用为true。是的,它已经存在于connfig中,但我认为您也应该将其添加到代码中。您确实应该解释在什么情况下需要这样做,因为如果没有它,这将不起作用;你说的没错,但是看看我的整个代码,告诉我我把代码放在哪里了?好吧,这个属性只能在代码中设置,不能在配置文件中指定。同样,您必须将该代码放入您的c代码中。请尝试
defaultCredentials=“false”
rene不工作问题仍然存在:(这些答案中任何有助于: