0

私はこの記事に大まかに基づいたアナウンスシステムを実装しています:

http://www.4guysfromrolla.com/articles/110409-1.aspx

私がする必要のある変更の1つは、ユーザーが読み取りのアナウンスを受け取った場合に、ユーザーのログイン後にモーダルポップアップを(ModalPopupExtenderを使用して)表示することです。

標準のログインコントロールのLoggedInイベントの後にユーザーがリダイレクトされるため、ポップアップは表示されません。どうすればそれを回避できますか?

Protected Sub Login1_LoggedIn(ByVal sender As Object, ByVal e As System.EventArgs) Handles Login1.LoggedIn
        'See if this user has unread announcements
        Dim announcementAPI As AnnouncementBLL = New AnnouncementBLL
        Dim UnreadAnnouncementCount As Integer= announcementAPI.GetUnreadAnnouncementCount(Login1.UserName)
        If UnreadAnnouncementCount > 0 Then
            UnreadAnnouncementMessage.Text = String.Format("You have {0} Announcement that you did not read yet.", UnreadAnnouncementCount)
            'Show modal popup for announcement!
            UnreadAnnouncementModalPopup.Show()

            'add soothing so user don't get redirected.

        End If

    End Sub
 Protected Sub Read_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Read.Click
        Response.Redirect(String.Format("~/Announcements.aspx?RedirectUrl={1}", _
                              Server.UrlEncode(FormsAuthentication.GetRedirectUrl(Login1.UserName, False))))

    End Sub

    Protected Sub Ignore_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Ignore.Click
        Response.Redirect(FormsAuthentication.GetRedirectUrl(Login1.UserName, False))
    End Sub
4

1 に答える 1

1

標準のログインコントロールを使用していると思いますか?リダイレクト動作をもう少し制御したい場合は、独自のログインコントロールを作成し、独自のリダイレクトロジックを挿入できます。

.NET認証メソッドを非常に簡単に利用できるため、独自のログインコントロールの作成は幸い非常に簡単です。ユーザーのユーザー名/パスワードを取得した後、以下の行を使用してユーザーのCookieを確認および設定できます。

If Membership.ValidateUser(username, password) Then
    ' add your redirect logic here
    FormsAuthentication.SetAuthCookie(username, rememberMe)
End If
于 2010-06-08T14:47:08.560 に答える