S
SAL
Hello,
We are designing a single logon site wide system here at my work. When my
page opens it checks for the existance of a cookie that another of our web
guys sets. It the cookie is present, I hit his webservice to get the user's
name. If the user is authenticated, I log them in using FormAuthentication.
All this seems to be working as expected and once the user is logged in, the
user is permitted to do that which has been defined via Roles in the
aspnetdb database and via my web.sitemap.
The problem is, the user is logged in and the sitemap doesn't refresh
without hitting the refresh button on the browser.
I'm doing all of the checking and logging users on in my master page. My
masterpage inherits from a class that inherits from
System.Web.UI.MasterPage.
I've tried several things to solve this problem such as,
redirecting to the requested URL to force a page refresh.
Calling the code for checking and logging on in different page events in the
Masterpage such as:
Page Load
Page Init
Page PreRender
None of them seem to solve this problem though. I'm fairly certain that most
of the problem is my lack of understanding about how things are occuring or
the order in which they are occuring.
I have a Table of Contents on the left side of the page that uses Repeater
that binds to a TableAdapter. The Repeater actually uses a business class
that returns the TableAdapter using rules according to the role the user is
loggin as. This also doesn't refresh properly just like the Menu which is
bound to my web.sitemap using the sitemap provider.
The code I'm using is as follows and is located in the MastePageBase.vb file
which the MasterPage inherits from:
This is called from the MasterPage's Load event.
Protected Sub ValidateLoggedIn()
If Session(CUR_USER) Is Nothing Then
If UserLoggedIn() Then
'Page.DataBind() ' I tried this but it didn't make a
difference
Response.Redirect(Request.Url.ToString())
End If
End If
End Sub
Public Function UserLoggedIn() As Boolean
If Not Session(CUR_USER) Is Nothing Then Return True
Dim cookieval As String = Nothing
Dim ccws As New checkCredentialsWS.checkCredentialsWS
If Not Request.Cookies(Searchs.JSESSIONID) Is Nothing Then
cookieval = Request.Cookies(Searchs.JSESSIONID).Value
End If
If cookieval Is Nothing Then
' For Production *************
Dim sred As String =
ConfigurationManager.AppSettings(LOGINPAGE_URL)
If Not sred Is Nothing Then ' Redirect them to the
login page
Response.Redirect(sred & "&postbackURL=" &
Request.Url.ToString())
End If
End If
If ccws.isLoginCookieIDMatch(cookieval) Then
Dim user As String = ccws.getUserName(cookieval)
If Not user = "" Then
FormsAuthentication.SetAuthCookie(user, False)
Session(CUR_USER) = user
Session(user) = True
End If
End If
End Function
Any help here is much appreciated.
S
We are designing a single logon site wide system here at my work. When my
page opens it checks for the existance of a cookie that another of our web
guys sets. It the cookie is present, I hit his webservice to get the user's
name. If the user is authenticated, I log them in using FormAuthentication.
All this seems to be working as expected and once the user is logged in, the
user is permitted to do that which has been defined via Roles in the
aspnetdb database and via my web.sitemap.
The problem is, the user is logged in and the sitemap doesn't refresh
without hitting the refresh button on the browser.
I'm doing all of the checking and logging users on in my master page. My
masterpage inherits from a class that inherits from
System.Web.UI.MasterPage.
I've tried several things to solve this problem such as,
redirecting to the requested URL to force a page refresh.
Calling the code for checking and logging on in different page events in the
Masterpage such as:
Page Load
Page Init
Page PreRender
None of them seem to solve this problem though. I'm fairly certain that most
of the problem is my lack of understanding about how things are occuring or
the order in which they are occuring.
I have a Table of Contents on the left side of the page that uses Repeater
that binds to a TableAdapter. The Repeater actually uses a business class
that returns the TableAdapter using rules according to the role the user is
loggin as. This also doesn't refresh properly just like the Menu which is
bound to my web.sitemap using the sitemap provider.
The code I'm using is as follows and is located in the MastePageBase.vb file
which the MasterPage inherits from:
This is called from the MasterPage's Load event.
Protected Sub ValidateLoggedIn()
If Session(CUR_USER) Is Nothing Then
If UserLoggedIn() Then
'Page.DataBind() ' I tried this but it didn't make a
difference
Response.Redirect(Request.Url.ToString())
End If
End If
End Sub
Public Function UserLoggedIn() As Boolean
If Not Session(CUR_USER) Is Nothing Then Return True
Dim cookieval As String = Nothing
Dim ccws As New checkCredentialsWS.checkCredentialsWS
If Not Request.Cookies(Searchs.JSESSIONID) Is Nothing Then
cookieval = Request.Cookies(Searchs.JSESSIONID).Value
End If
If cookieval Is Nothing Then
' For Production *************
Dim sred As String =
ConfigurationManager.AppSettings(LOGINPAGE_URL)
If Not sred Is Nothing Then ' Redirect them to the
login page
Response.Redirect(sred & "&postbackURL=" &
Request.Url.ToString())
End If
End If
If ccws.isLoginCookieIDMatch(cookieval) Then
Dim user As String = ccws.getUserName(cookieval)
If Not user = "" Then
FormsAuthentication.SetAuthCookie(user, False)
Session(CUR_USER) = user
Session(user) = True
End If
End If
End Function
Any help here is much appreciated.
S