用户登录后如何打开新窗口(登录控件)?

时间:2012-04-19 15:28:50

标签: asp.net

将打开一个新的弹出窗口,但会将其重定向到登录页面,并且基页也无法通过显示不正确的密码进行登录。要求:登录后我们需要一个弹出窗口,浏览器上没有任何BACK按钮。

<asp:Content ID="LoginContent" ContentPlaceHolderID="LoginContent" runat="server">
      <asp:UpdatePanel ID="LoginUpdatePanel" runat="server" UpdateMode="Conditional">
        <ContentTemplate>
            <asp:Panel Width="100%" runat="server" ID="LoginPanel" HorizontalAlign="Center" DefaultButton="MainLogin$LoginButton">
                <asp:Label ID="LoginMessageValue" runat="server"></asp:Label>
                <asp:Login RememberMeSet="false" ID="MainLogin" OnLoggedIn="MainLogin_LoggedIN"  OnAuthenticate="Login_Click" runat="server" SkinID="standardLoginObject" EnableTheming="True"
                  TextBoxStyle-Width="150px" DisplayRememberMe="false">
                </asp:Login>
            </asp:Panel>
        </ContentTemplate>
    </asp:UpdatePanel>
</asp:Content>

代码背后:

Protected Sub Login_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        'OnAuthenticate = "Login_Click"
        ' ScriptManager.RegisterClientScriptBlock(Me.Page, Me.GetType, "error", "window.open('~/workflow/Worklist2.aspx', 'mywindow', 'status=1,toolbar=0');", True)
        Try
            Common.UserObject = System.Web.Security.Membership.GetUser(MainLogin.UserName)

            Dim _userID As Integer = Common.UserObject.ProviderUserKey
            Common.InitializeSession(_userID, nameSpaceURI)
            Dim _role() As String = System.Web.Security.Roles.GetRolesForUser(Common.UserObject.UserName)
            If _role.Length = 0 Then
                Common.ClearSession()
                Response.Redirect(ConfigurationManager.AppSettings("LoginPath"), False)
                'MainLogin.FailureText = "Please contact the customer service to review your account setup."
                'ClientScript.RegisterClientScriptBlock(Page.GetType, "Error", "alert('Please contact the customer service to review your account setup.')", True)
            End If
            ScriptManager.RegisterClientScriptBlock(Me.Page, Me.GetType, "success", "window.open('../workflow.aspx', 'mywindow', 'status=1,toolbar=0'); window.resizeTo(screen.availWidth,screen.availHeight); window.moveTo(0,0); ", True)
        Catch ex As Exception
            SaveException(ex)
        End Try
    End Sub

1 个答案:

答案 0 :(得分:0)

我认为您真正的问题是您正在尝试显示错误页面,该页面还要求用户通过身份验证才能看到它。

您应该将错误页面移动到公开可见的位置。

您可以在web.config中指定此行为:

<configuration>
   <location path="~/errorpage.aspx">
      <system.web>
         <authorization>
            <allow users="?"/>
         </authorization>
      </system.web>
   </location>
</configuration>
相关问题