PasswordRecovery控件在asp.net [英] PasswordRecovery control in asp.net

查看:124
本文介绍了PasswordRecovery控件在asp.net的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创造了我的web应用程序和用户 PasswordRecovery 控制。
我的code在HTML:

< ASP:PasswordRecovery ID =PasswordRecovery1=服务器>
     < MailDefinition从=hsadeghi.t@gmail.com主题=ResetPassword
      优先级为高/>
< / ASP:PasswordRecovery>

和我的web.config code是:

< system.net>
     < mailSettings>
        < SMTP deliveryMethod =从=hsadeghi.t@gmail.com&GT网络;
           <网络
              主机=smtp.gmail.com
              端口=25
              密码=XXXXXXX
              的DefaultCredentials =真/>
        < / SMTP>
     < / mailSettings>
< /system.net>

但我得到这些错误,这是行不通的。


  

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


  
  

2-A连接尝试失败,因为连接的方没有正确一段时间后响应或已建立的连接失败,因为连接主机未能响应173.194.66.109:25



我的web.config code是

<结构>
    <&的System.Web GT;
        < roleManager启用=真/>
        <身份验证模式=表格/>
        <编译调试=真targetFramework =4.5/>
        <的httpRuntime targetFramework =4.5/>
    < /system.web>    <! - ... - >    < system.net>
        < mailSettings>
            <从=hsadeghi.t@gmail.com&GT SMTP;
                <网络主机=smtp.gmail.com密码=输入mypassword
                 enableSsl =真正的端口=578的userName =hsadeghi.t@gmail.com/>
            < / SMTP>
        < / mailSettings>
    < /system.net>
< /结构>

和形式:

<%@页标题=LANGUAGE =C#的MasterPageFile =〜/硕士/主店。主
  AutoEventWireup =真codeBehind =UserPasswordRecovery.aspx.cs
  继承=Store.Pages.userpasswordrecovery%GT;<! - ... - >
< ASP:内容ContentPlaceHolderID =ContentPlaceHolder1=服务器>
    < D​​IV CLASS =包装>
        < D​​IV CLASS =包装轮辋>
            < D​​IV CLASS =网站内容>
                < D​​IV CLASS =恢复密码DIR =RTL>
                    < ASP:PasswordRecovery ID =PasswordRecovery1=服务器/>
                < / DIV>
            < / DIV>
        < / DIV>
    < / DIV>
< / ASP:内容>


解决方案

除了在配置中启用SSL,您还需要设置正确的端口,这是的 25.这是587。

< SMTP deliveryMethod =网络,从=someaccount@gmail.com>
   <网络
      主机=smtp.gmail.com
      端口=587
      enableSsl =真
      的userName =someaccount@gmail.com
      密码=somepassword
      的DefaultCredentials =FALSE/>
< / SMTP>

I created my web application and user PasswordRecovery Control. My code in html :

<asp:PasswordRecovery ID="PasswordRecovery1" runat="server">
     <MailDefinition From="hsadeghi.t@gmail.com" Subject="ResetPassword"
      Priority="High"/>
</asp:PasswordRecovery>

And my web.config code is:

<system.net>
     <mailSettings>
        <smtp deliveryMethod="Network" from="hsadeghi.t@gmail.com">
           <network
              host="smtp.gmail.com"
              port="25"
              password="xxxxxxx"
              defaultCredentials="true"/>
        </smtp>
     </mailSettings>
</system.net>

But I get these errors and it doesn't work.

1-The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required.

2-A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 173.194.66.109:25


my web.config code is

<configuration>
    <system.web>
        <roleManager enabled="true" />
        <authentication mode="Forms" />
        <compilation debug="true" targetFramework="4.5" />
        <httpRuntime targetFramework="4.5" />
    </system.web>

    <!-- ... -->

    <system.net>
        <mailSettings>
            <smtp from="hsadeghi.t@gmail.com">
                <network host="smtp.gmail.com" password="mypassword"
                 enableSsl="true" port="578" userName="hsadeghi.t@gmail.com" />
            </smtp>
        </mailSettings>
    </system.net>
</configuration>

and form :

<%@ Page Title="" Language="C#" MasterPageFile="~/Masters/master-store.Master"
  AutoEventWireup="true" CodeBehind="UserPasswordRecovery.aspx.cs"
  Inherits="Store.Pages.userpasswordrecovery" %>

<!-- ... -->
<asp:Content ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <div class="wrapper">
        <div class="wrapper-rim">
            <div class="site-content">
                <div class="recovery-password" dir="rtl">
                    <asp:PasswordRecovery ID="PasswordRecovery1" runat="server"/>
                </div>
            </div>
        </div>
    </div>
</asp:Content>

解决方案

Aside from enabling ssl in your configuration, you also need to set the correct port, which is not 25. It's 587.

<smtp deliveryMethod="Network" from="someaccount@gmail.com">
   <network
      host="smtp.gmail.com"
      port="587"  
      enableSsl="true"
      userName="someaccount@gmail.com"
      password="somepassword"
      defaultCredentials="false"/>
</smtp>

这篇关于PasswordRecovery控件在asp.net的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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