문제

For my authentication I use a generated token which is part of the query string. If this is invalid or empty the user will be redirected to the logon page. On this I use a Login control to authenticate the user and create the token. This works fine.

Protected Sub LoginUser_Authenticate(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.AuthenticateEventArgs) Handles LoginUser.Authenticate
  'check if user is authenticated

  e.Authenticated = bUserIsAuthenticated
End Sub

Protected Sub LoginUser_LoggedIn(ByVal sender As Object, ByVal e As System.EventArgs) Handles LoginUser.LoggedIn
  'create token and redirect back to main page
End Sub

I use LoginName control to show the name of the current user. The combination from user name and token is saved in a XML file.

Now I got a problem in the following case: an user calls the page with an valid token (http://MyServer/MyWebSite/Page.aspx?Token=abcd1234). The name of the user will not be shown in the LoginName control because he is not authenticated to the page. How can I authenticate this user to the page with my own user management?

도움이 되었습니까?

해결책

I could solve it myself. I only have to call

FormsAuthentication.SetAuthCookie("MyUserName", False)
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top