创建帐户后不让用户登录

问题描述:

我有一个简单的创建用户向导控件,它现在工作得很好。 问题是我想禁用后,他创造他的帐户创建日志的用户,我能够做到这一点,只需DisableCreatedUser属性设置为true创建帐户后不让用户登录

但不幸的是,当我尝试创建后立即刷新页面帐户和检查它显示我的用户登录。

如果用户直接点击登录,并检查它给我一个错误,他需要激活他的帐户。

那么,如何禁用用户,虽然他试图刷新页面?

任何帮助将不胜感激!

<asp:UpdatePanel ID="UpdatePanel1" runat="server"> 
      <ContentTemplate> 
      <asp:CreateUserWizard ID="CreateUserWizard1" runat="server" 
        DisableCreatedUser="True" 
        LoginCreatedUser="False"> 
      <ContinueButtonStyle BorderStyle="None" CssClass="btn big" Font-Size="12px"/> 
      <CreateUserButtonStyle CssClass="btn big" Height="30px" 
         Width="125px" BorderStyle="None" Font-Size="12px" /> 

      <WizardSteps> 
       <asp:CreateUserWizardStep ID="CreateUserWizardStep1" runat="server"> 
        <ContentTemplate> 
        <table> 
        <tr> 
        <td align="right"> 
        <asp:Label ID="UserNameLabel" runat="server" AssociatedControlID="UserName" style="z-index:2; position:relative !important;">User Name:</asp:Label> 
        </td> 
        <td> 
        <asp:TextBox ID="UserName" runat="server" BorderStyle="Solid" BorderWidth="1px" BorderColor="#0099CC" BackColor="#FAFFBD"></asp:TextBox> 
        <asp:RequiredFieldValidator ID="UserNameRequired" runat="server" 
               ControlToValidate="UserName" ErrorMessage="User Name is required." 
               ToolTip="User Name is required." ValidationGroup="CreateUserWizard1" 
               CssClass="signupvalidators" ForeColor="Red">*</asp:RequiredFieldValidator> 
        </td> 
        </tr> 
            <tr> 
             <td align="right"> 
              <asp:Label ID="PasswordLabel" runat="server" AssociatedControlID="Password" style="z-index:2; position:relative !important;">Password:</asp:Label> 
             </td> 
             <td> 
              <asp:TextBox ID="Password" runat="server" TextMode="Password" BorderStyle="Solid" BorderWidth="1px" BorderColor="#0099CC" BackColor="#FAFFBD"></asp:TextBox> 
              <asp:RequiredFieldValidator ID="PasswordRequired" runat="server" 
               ControlToValidate="Password" ErrorMessage="Password is required." 
               ToolTip="Password is required." ValidationGroup="CreateUserWizard1" 
               CssClass="signupvalidators" ForeColor="Red">*</asp:RequiredFieldValidator> 
             </td> 
            </tr> 
            <tr> 
             <td align="right"> 
              <asp:Label ID="ConfirmPasswordLabel" runat="server" 
               AssociatedControlID="ConfirmPassword" style="z-index:2; position:relative !important;">Confirm Password:</asp:Label> 
             </td> 
             <td> 
              <asp:TextBox ID="ConfirmPassword" runat="server" TextMode="Password" BorderStyle="Solid" BorderWidth="1px" BorderColor="#0099CC" BackColor="#FAFFBD"></asp:TextBox> 
              <asp:RequiredFieldValidator ID="ConfirmPasswordRequired" runat="server" 
               ControlToValidate="ConfirmPassword" 
               ErrorMessage="Confirm Password is required." 
               ToolTip="Confirm Password is required." 
               ValidationGroup="CreateUserWizard1" CssClass="signupvalidators" ForeColor="Red">*</asp:RequiredFieldValidator> 
             </td> 
            </tr> 
            <tr> 
             <td align="right"> 
              <asp:Label ID="EmailLabel" runat="server" AssociatedControlID="Email" style="z-index:2; position:relative !important;">E-mail:</asp:Label> 
             </td> 
             <td> 
              <asp:TextBox ID="Email" runat="server" BorderStyle="Solid" BorderWidth="1px" BorderColor="#0099CC" BackColor="#FAFFBD"></asp:TextBox> 
              <asp:RequiredFieldValidator ID="EmailRequired" runat="server" 
               ControlToValidate="Email" ErrorMessage="E-mail is required." 
               ToolTip="E-mail is required." ValidationGroup="CreateUserWizard1" 
               CssClass="signupvalidators" ForeColor="Red">*</asp:RequiredFieldValidator> 
             </td> 
            </tr> 
            <tr> 
             <td align="right"> 
              <asp:Label ID="QuestionLabel" runat="server" AssociatedControlID="Question" style="z-index:2; position:relative !important;">Security Question:</asp:Label> 
             </td> 
             <td> 
              <asp:TextBox ID="Question" runat="server" BorderStyle="Solid" BorderWidth="1px" BorderColor="#0099CC" BackColor="#FAFFBD"></asp:TextBox> 
              <asp:RequiredFieldValidator ID="QuestionRequired" runat="server" 
               ControlToValidate="Question" ErrorMessage="Security question is required." 
               ToolTip="Security question is required." 
               ValidationGroup="CreateUserWizard1" CssClass="signupvalidators" ForeColor="Red">*</asp:RequiredFieldValidator> 
             </td> 
            </tr> 
            <tr> 
             <td align="right"> 
              <asp:Label ID="AnswerLabel" runat="server" AssociatedControlID="Answer" style="z-index:2; position:relative !important;">Security Answer:</asp:Label> 
             </td> 
             <td> 
              <asp:TextBox ID="Answer" runat="server" BorderStyle="Solid" BorderWidth="1px" BorderColor="#0099CC" BackColor="#FAFFBD"></asp:TextBox> 
              <asp:RequiredFieldValidator ID="AnswerRequired" runat="server" 
               ControlToValidate="Answer" ErrorMessage="Security answer is required." 
               ToolTip="Security answer is required." ValidationGroup="CreateUserWizard1" 
               CssClass="signupvalidators" ForeColor="Red">*</asp:RequiredFieldValidator> 
             </td> 
            </tr> 
           <tr> 
           <td align="center" colspan="2"> 
            <asp:RegularExpressionValidator ID="UsernameLength" runat="server" 
             ErrorMessage="Username should be minimum 5-10 characters." 
             ControlToValidate="UserName" Display="Dynamic" ForeColor="Red" 
             ValidationExpression="^[\s\S]{5,10}$" ValidationGroup="CreateUserWizard1"></asp:RegularExpressionValidator> 
           </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" ForeColor="Red"></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> 
            <tr> 
            <td align="center" colspan="2"> 
            <asp:RegularExpressionValidator ID="PasswordLength" runat="server" Display="Dynamic" 
               ErrorMessage="Password length minimum: 7. Non-alphanumeric characters required: 1" 
               ControlToValidate="Password" ValidationExpression="(?=^.{7,51}$)([A-Za-z]{1})([[email protected]#$%_\^\&amp;\*\-\.\?]{5,49})$" 
              ForeColor="Red" ValidationGroup="CreateUserWizard1"></asp:RegularExpressionValidator> 
            </td> 
            </tr> 
            <tr> 
            <td align="center" colspan="2"> 
             <asp:RegularExpressionValidator ID="EmailValidator" runat="server" Display="Dynamic" 
              ControlToValidate="Email" ErrorMessage="Please enter a valid e-mail address." ValidationExpression="^[\w-]+(\.[\w-]+)*@([a-z0-9-]+(\.[a-z0-9-]+)*?\.[a-z]{2,6}|(\d{1,3}\.){3}\d{1,3})(:\d{4})?$" ForeColor="Red" ValidationGroup="CreateUserWizard1"></asp:RegularExpressionValidator> 
            </td> 
            </tr> 
           </table> 

           <asp:UpdateProgress ID="UpdateProgressUserDetails" runat="server" DisplayAfter="0"> 
             <ProgressTemplate> 
              <div style="position: absolute; top: 215px; left:140px;"> 
               <img src="img/Loader.gif" alt="loading" /><br /> 
               <%-- <span style="font-weight: bold; font-size: large; color: #000000;">Please wait...</span>--%> 
              </div> 
             </ProgressTemplate> 
            </asp:UpdateProgress> 
          </ContentTemplate> 
         </asp:CreateUserWizardStep> 
         <asp:CompleteWizardStep ID="CompleteWizardStep1" runat="server"> 
         </asp:CompleteWizardStep> 
        </WizardSteps> 
       </asp:CreateUserWizard> 
+0

我与具有用户注册的概念挣扎,但你马上把它们锁在应用程序之外。 – DOK 2012-01-15 18:52:58

+0

这只是简单的,我创建新的用户,然后它显示我用户已成功创建。在这里一切都很好。现在当我立即刷新页面显示用户已登录,虽然我已禁用他的帐户。 – coder 2012-01-15 18:54:42

+0

向我们展示wizardsteps。 – 2012-01-15 19:04:31

我终于发现了解决方案,这是因为在这一条线上的我的后台代码:

FormsAuthentication.SetAuthCookie(CreateUserWizard1.UserName, False) 

设置LoginCreatedUserfalse

DisableCreatedUser注:

当DisableCreatedUser是真实的,你应该设置LoginCreatedUser 属性设置为false,以使CreateUserWizard控件不会尝试对新用户登录 。

LoginCreatedUser Reamrks:

的LoginCreatedUser属性可以,如果你想 创建一个用户帐户之后却是创造 无法验证帐户设置为false。例如,如果您是管理员创建 用户帐户,或者在 用户可以访问该网站之前有一个等待期,这可能会很有用。

+0

@ Tim-谢谢您的回复,因为我已经在我的编辑中设置了该属性,但它仍然显示用户已登录。 – coder 2012-01-15 19:00:16