0

CreateUserWizard でユーザーを作成します CreateUserWizard を Updatepanel に同封しました。ユーザーが作成され、更新がブラウザ コンソールに呼び出されると、エラーが表示され、更新パネルが更新されません。

    Uncaught Sys.WebForms.PageRequestManagerServerErrorException: Sys.WebForms.PageRequestManagerServerErrorException: An unknown error occurred while processing the request on the server. The status code returned from the server was: 500 ScriptResource.axd:513


          <asp:UpdatePanel UpdateMode="Conditional"  runat="server" ID="UpdatePanelCreateUser">
                <ContentTemplate>
                    <asp:CreateUserWizard ID="CreateUserWizard1" runat="server" CompleteSuccessText="Successful. Confirmation mail has been sent to the Email address. Follow the link to confirm your account."
                        DisableCreatedUser="true" LoginCreatedUser="false" OnCreatedUser="CreateUserWizard1_CreatedUser"
                        OnCreatingUser="CreateUserWizard1_CreatingUser" 
                        onsendingmail="CreateUserWizard1_SendingMail1" >
                        <MailDefinition BodyFileName="~/MailFile.txt" From="spiralswhirls@yahoo.com" >

                        </MailDefinition>
                        <WizardSteps>
                            <asp:CreateUserWizardStep runat="server">
                                <ContentTemplate>
                                    <table border="0">
                                        <tr>
                                            <td align="center" colspan="2">
                                                &nbsp;
                                            </td>
                                        </tr>
                                        <tr>
                                            <td align="right">
                                                <asp:Label ID="UserNameLabel" runat="server" AssociatedControlID="UserName" Visible="false">User Name:</asp:Label>
                                            </td>
                                            <td>
                                                <asp:TextBox ID="UserName" runat="server" Visible="false"></asp:TextBox>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td align="right">
                                                <asp:Label ID="Label2" runat="server">First Name:</asp:Label>
                                            </td>
                                            <td>
                                                <asp:TextBox ID="TextBoxFirstName" runat="server"></asp:TextBox>
                                                <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="TextBoxFirstName"
                                                    ErrorMessage="User Name is required." ToolTip="User Name is required." ValidationGroup="CreateUserWizard1">*</asp:RequiredFieldValidator>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td align="right">
                                                <asp:Label ID="LabelLastName" runat="server">Last Name:</asp:Label>
                                            </td>
                                            <td>
                                                <asp:TextBox ID="TextBoxLastName" runat="server"></asp:TextBox>
                                                <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="TextBoxLastName"
                                                    ErrorMessage="User Name is required." ToolTip="User Name is required." ValidationGroup="CreateUserWizard1">*</asp:RequiredFieldValidator>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td align="right">
                                                <asp:Label ID="PasswordLabel" runat="server" AssociatedControlID="Password">Password:</asp:Label>
                                            </td>
                                            <td>
                                                <asp:TextBox ID="Password" runat="server" TextMode="Password"></asp:TextBox>
                                                <asp:RequiredFieldValidator ID="PasswordRequired" runat="server" ControlToValidate="Password"
                                                    ErrorMessage="Password is required." ToolTip="Password is required." ValidationGroup="CreateUserWizard1">*</asp:RequiredFieldValidator>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td align="right">
                                                <asp:Label ID="ConfirmPasswordLabel" runat="server" AssociatedControlID="ConfirmPassword">Confirm Password:</asp:Label>
                                            </td>
                                            <td>
                                                <asp:TextBox ID="ConfirmPassword" runat="server" TextMode="Password"></asp:TextBox>
                                                <asp:RequiredFieldValidator ID="ConfirmPasswordRequired" runat="server" ControlToValidate="ConfirmPassword"
                                                    ErrorMessage="Confirm Password is required." ToolTip="Confirm Password is required."
                                                    ValidationGroup="CreateUserWizard1">*</asp:RequiredFieldValidator>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td align="right">
                                                <asp:Label ID="EmailLabel" runat="server" AssociatedControlID="Email">E-mail:</asp:Label>
                                            </td>
                                            <td>
                                                <asp:TextBox ID="Email" runat="server"></asp:TextBox>
                                                <asp:RequiredFieldValidator ID="EmailRequired" runat="server" ControlToValidate="Email"
                                                    ErrorMessage="E-mail is required." ToolTip="E-mail is required." ValidationGroup="CreateUserWizard1">*</asp:RequiredFieldValidator>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td align="right">
                                                <asp:Label ID="LabelSex" runat="server" AssociatedControlID="DropDownListSex">Sex:</asp:Label>
                                            </td>
                                            <td>
                                                <asp:DropDownList ID="DropDownListSex" runat="server">
                                                    <asp:ListItem>Male</asp:ListItem>
                                                    <asp:ListItem>Female</asp:ListItem>
                                                </asp:DropDownList>
                                                <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ControlToValidate="DropDownListSex"
                                                    ErrorMessage="E-mail is required." ToolTip="E-mail is required." ValidationGroup="CreateUserWizard1">*</asp:RequiredFieldValidator>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td colspan="2" style="padding-left: 10px;">
                                                <BotDetect:Captcha ID="Captcha1" runat="server" CodeLength="7" />
                                                <asp:TextBox ID="TextBox1" runat="server" Width="280px"></asp:TextBox>
                                                <div>
                                                    <asp:Label runat="server" ID="LabelCaptcha" Style="font-size: 11px;"></asp:Label>
                                                </div>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td align="center" colspan="2">
                                                <asp:CompareValidator ID="PasswordCompare" runat="server" ControlToCompare="Password"
                                                    ControlToValidate="ConfirmPassword" Display="Dynamic" ErrorMessage="The Password and Confirmation Password must match."
                                                    ValidationGroup="CreateUserWizard1"></asp:CompareValidator>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td align="center" colspan="2" style="color: Red;">
                                                <asp:Literal ID="ErrorMessage" runat="server" EnableViewState="False"></asp:Literal>
                                            </td>
                                        </tr>
                                    </table>
                                </ContentTemplate>
                            </asp:CreateUserWizardStep>
                            <asp:CompleteWizardStep runat="server" />
                        </WizardSteps>
                    </asp:CreateUserWizard>
                </ContentTemplate>
            </asp:UpdatePanel>

CreatedUser イベント

     protected void CreateUserWizard1_CreatedUser(object sender, EventArgs  e)
    {
    TextBox textboxemail = (TextBox)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("Email"); 
    MembershipUser user = Membership.GetUser(textboxemail.Text);
    Guid userid = (Guid)user.ProviderUserKey;
    TextBox firstname = (TextBox)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("TextBoxFirstName");
    TextBox lastname = (TextBox)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("TextBoxLastName");
    DropDownList sex = (DropDownList)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("DropDownListSex");
    ProfileDataAccess.SaveUserName(firstname.Text, null, lastname.Text, Convert.ToString (userid));
    ProfileDataAccess.SaveSex(sex.SelectedValue, Convert.ToString(userid));
    ProfileDataAccess.SetProfilePictureForNewUser(userid, 0);
    //CreateUserWizard1.MailDefinition.From = "autogenerated@studentjoin.com";
    Label labelCaptcha = (Label)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("LabelCaptcha");
    labelCaptcha.Text = "";
}

メール送信イベント

    protected void CreateUserWizard1_SendingMail1(object sender, MailMessageEventArgs e)
  { 
   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);

   UpdatePanelCreateUser.Update();

}

}

4

1 に答える 1

0

問題は解決されました。実際には、実行が終了した後に例外が発生しましたsendingmail。そのため、 以外でその例外をキャッチする方法はありませんでしたApplication_Error。だから私はそこに移動してCreatedUserそこから手動でメールを送信しようとし、手動でキャンセルするために例外があればキャッチし、createduser作成したユーザーを削除しました。

于 2013-07-06T12:56:00.980 に答える