Object reference not set to an instance of an object when sending URL
<p>I have a password recovery controls in my web form. 
Upon entering all the necessary particular, an email will be send to the user's email account. </p>

<p>It would be like -- if a user forgets his/her password, sending a password change link to the user's email account instead of a new password.  </p>

<p>However, after clicking on the submit button, " Object reference not set to an instance of an object." error appear. </p>

<pre><code>Exception Details: System.NullReferenceException: Object reference not set to an instance of an object. And the error occurred on line 66. 

Source Error: 

Line 64:         System.Web.UI.WebControls.Login Login1 =   (System.Web.UI.WebControls.Login)LoginView1.FindControl("Login1");   
Line 65:         MembershipUser pwRecover = Membership.GetUser(Login1.UserName);
**Line 66:         Guid userInfoId2 = (Guid)pwRecover.ProviderUserKey;**
</code></pre>

<p>Following is the the behind code for the sending url in the message body: </p>

<pre><code> protected void PasswordRecovery1_SendingMail(object sender, MailMessageEventArgs e)
{

    System.Web.UI.WebControls.Login Login1 = (System.Web.UI.WebControls.Login)LoginView1.FindControl("Login1");   
    MembershipUser pwRecover = Membership.GetUser(Login1.UserName);
    Guid userInfoId2 = (Guid)pwRecover.ProviderUserKey;


    //Create an url that will link to a UserProfile.aspx and
    //accept a query string that is the user's id

    //setup the base of the url
    string domainName = Request.Url.GetLeftPart(UriPartial.Authority) + Request.ApplicationPath;

    //setup the second half of the url
    string confirmationPage = "/UserProfile.aspx?ID=" + userInfoId2.ToString();

    //combine to make the final url
    string url = domainName + confirmationPage;

    // Replace &lt;%VerifyUrl%&gt; placeholder with url value
    e.Message.Body = e.Message.Body.Replace("&lt;%ResetPassword%&gt;", url);
}
</code></pre>
