我的网站允许用户创建帐户。
创建后,带有 URL 的电子邮件验证将发送到用户的电子邮件。
问题:电子邮件发送成功,但不幸的是验证 URL 没有出现。
而对于
<a href="<%VerifyUrl%>"<%verifyUrl%></a></p>
“<%VerifyUrl%>”下面有一个绿色的卷线,表示找不到这个文件。
这是 Login.aspx 的源代码:
protected void CreateUserWizard1_SendingMail(object sender,MailMessageEventArgs e)
{
MembershipUser userInfo = Membership.GetUser(CreateUserWizard1.UserName);
//Construct the verification URL
string verifyUrl = Request.Url.GetLeftPart(UriPartial.Authority) + Page.ResolveUrl("~/Verify.aspx?ID=" + userInfo.ProviderUserKey.ToString());
// Replace <%VerifyUrl%> placeholder with verifyUrl value
e.Message.Body = e.Message.Body.Replace("VerifyUrl", verifyUrl.ToString());
}
这是用户将在他们的电子邮件中看到的 html 文件:
<h2> Welcome to My Website!</h2>
<p>
Hello, <%UserName%>. You are receiving this email because you recently created a new account at my
site. Before you can login, however, you need to first visit the following link:</p>
<p>
<a href="<%VerifyUrl%>"><%verifyUrl%></a></p>
<p>
After visiting the above link you can log into the site!</p>
<p>
If you have any problems verifying your account, please reply to this email to
get assistance.</p>
<p>
Thanks!</p>