0

我应该如何处理那些我无法在后面的 C# 代码中捕获的异常......例如,我面临电子邮件发送失败system.Net.Sockets.SocketException但我没有机会处理页面代码隐藏......我应该在哪里处理它?

protected void CreateUserWizard1_SendingMail1(object sender, MailMessageEventArgs e)
{
    string emailname="";
    try
    {
        TextBox textboxemail = (TextBox)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("Email");
        MembershipUser user = Membership.GetUser(textboxemail.Text);
        Guid userid = (Guid)user.ProviderUserKey;
        string verificationurl = "http://www.spiralsnet.com/Login.aspx?NewUserId=" + userid.ToString();
        e.Message.IsBodyHtml = true;
        e.Message.From = new System.Net.Mail.MailAddress("SpiralsWhirls@yahoo.com", "SpiralsNet");
        e.Message.Body = e.Message.Body.Replace("<%VU%>", verificationurl);
    }
    catch (System.Net.Sockets.SocketException ex)
    {
        Membership.DeleteUser(emailname);
    }

}
4

0 回答 0