May 18, 2018 06:24 AM|Brando ZWZ|LINK
As far as I know, the identity is not as same as form authentication.
We couldn't enable the form authentication to login user.
The identity user token is not as same as form authentication user ticket.
They are different things.
If you want to enable auto redirect unauthorized user to login page.
I suggest you could write logic in the master page's page load event to check the user is unauthorized.
More details, you could refer to below codes:
In the master Page load event write this code, add a property named IsLoginRequired.
By using this property we could set the page is not required login by setting the IsLoginRequired to false.
Public m_bLoginRequired As Boolean = True
Public Property IsLoginRequired As Boolean
Set(ByVal value As Boolean)
m_bLoginRequired = value
Then in Master page page load event we could check the user is login and the page require login.
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If IsLoginRequired = True Then
If Not HttpContext.Current.User.Identity.IsAuthenticated Then
Then in the login page:
We could modify the master page IsLoginRequired to false in Page_PreInit event:
Partial Public Class Login
Protected Sub Page_PreInit(ByVal sender As Object, ByVal e As EventArgs) Handles Me.PreInit
Dim masterpage As SiteMaster = CType((Page.Master), SiteMaster)
masterpage.IsLoginRequired = False