views:

442

answers:

2

I am trying to understand the password recovery technique on asp.net membership.

This is my web.config file:

<?xml version="1.0"?>
<!-- 
    Note: As an alternative to hand editing this file you can use the 
    web admin tool to configure settings for your application. Use
    the Website->Asp.Net Configuration option in Visual Studio.
    A full list of settings and comments can be found in 
    machine.config.comments usually located in 
    \Windows\Microsoft.Net\Framework\v2.x\Config 
-->
<configuration>
    <appSettings/>  
  <connectionStrings>
    <remove name="LocalSqlServer"/>
    <add name="LocalSqlServer" connectionString="Data Source=localhost;Initial Catalog=aspnet_membership_test;Integrated Security=True" providerName="System.Data.SqlClient"/>
  </connectionStrings>
    <system.web>
     <!-- 
            Set compilation debug="true" to insert debugging 
            symbols into the compiled page. Because this 
            affects performance, set this value to true only 
            during development.
        -->
     <compilation debug="true"/>
     <!--
            The <authentication> section enables configuration 
            of the security authentication mode used by 
            ASP.NET to identify an incoming user. 
        -->
    <authentication mode="Forms">
      <forms loginUrl="~/Login.aspx">         
      </forms>      
    </authentication>
    <authorization>
      <allow users="*"/>      
    </authorization>
     <!--
            The <customErrors> section enables configuration 
            of what to do if/when an unhandled error occurs 
            during the execution of a request. Specifically, 
            it enables developers to configure html error pages 
            to be displayed in place of a error stack trace.

        <customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
            <error statusCode="403" redirect="NoAccess.htm" />
            <error statusCode="404" redirect="FileNotFound.htm" />
        </customErrors>
        -->
    </system.web>

  <location path="SecuredPage.aspx">
    <system.web>
      <authorization>
        <deny users="?"/>
      </authorization>
    </system.web>
  </location>

  <system.net>
    <mailSettings>
      <smtp deliveryMethod="Network" from="[email protected]">
        <network host="mail.yahoo.com"
        port="25" defaultCredentials="true"/>
      </smtp>
    </mailSettings>
  </system.net>




</configuration>

But I am getting this error from IIS:

Server Error in '/Web' Application.
--------------------------------------------------------------------------------

An established connection was aborted by the software in your host machine 69.147.112.160:25 
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.Net.Sockets.SocketException: An established connection was aborted by the software in your host machine 69.147.112.160:25

Source Error: 

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.  

Stack Trace: 


[SocketException (0x2745): An established connection was aborted by the software in your host machine 69.147.112.160:25]
   System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress) +198
   System.Net.Sockets.Socket.InternalConnect(EndPoint remoteEP) +60
   System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Int32 timeout, Exception& exception) +579

[WebException: Unable to connect to the remote server]
   System.Net.ServicePoint.GetConnection(PooledStream PooledStream, Object owner, Boolean async, IPAddress& address, Socket& abortSocket, Socket& abortSocket6, Int32 timeout) +406
   System.Net.PooledStream.Activate(Object owningObject, Boolean async, Int32 timeout, GeneralAsyncDelegate asyncCallback) +288
   System.Net.PooledStream.Activate(Object owningObject, GeneralAsyncDelegate asyncCallback) +46
   System.Net.ConnectionPool.GetConnection(Object owningObject, GeneralAsyncDelegate asyncCallback, Int32 creationTimeout) +429
   System.Net.Mail.SmtpConnection.GetConnection(String host, Int32 port) +333
   System.Net.Mail.SmtpTransport.GetConnection(String host, Int32 port) +287
   System.Net.Mail.SmtpClient.GetConnection() +56
   System.Net.Mail.SmtpClient.Send(MailMessage message) +1679

[SmtpException: Failure sending mail.]
   System.Net.Mail.SmtpClient.Send(MailMessage message) +2246
   System.Web.UI.WebControls.LoginUtil.SendPasswordMail(String email, String userName, String password, MailDefinition mailDefinition, String defaultSubject, String defaultBody, OnSendingMailDelegate onSendingMailDelegate, OnSendMailErrorDelegate onSendMailErrorDelegate, Control owner) +482
   System.Web.UI.WebControls.PasswordRecovery.AttemptSendPasswordQuestionView() +748
   System.Web.UI.WebControls.PasswordRecovery.AttemptSendPassword() +106
   System.Web.UI.WebControls.PasswordRecovery.OnBubbleEvent(Object source, EventArgs e) +136
   System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +56
   System.Web.UI.WebControls.Button.OnCommand(CommandEventArgs e) +107
   System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +178
   System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +31
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +32
   System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +72
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3825




--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.50727.1433; ASP.NET Version:2.0.50727.1433

What could be the problem?

A: 

I think you are using the wrong port for Yahoo's SMTP server. According to this link you ought to be using port 465.

Andrew Hare
Your solution is not working.
+1  A: 

It looks like you're trying to send your email using Yahoo's server. If you haven't signed up for their premium mail you won't be allowed to do so.

Check out this reference for setting it up properly if you do have the service:

http://help.yahoo.com/l/us/yahoo/mail/classic/mailplus/pop/pop-14.html

womp
May be you are correct. But how can I test this membership feature alternatively (i.e. without signing up in Yahoo or any other provider)?
You need to set up your local IIS to enable SMTP and use that as your mail server. Alternately, find someone that will give you a free SMTP account, like gmail. http://lifehacker.com/111166/how-to-use-gmail-as-your-smtp-server
womp