A
Andrew Parsons
Hi all,
I had a weird issue with trying to use a cookie in a ASCX housed on my web
forms and I was wondering if I am missing something.
I wanted to use the authenticated cookie for the user name logged into the
web site to show the user that they are logged on. If I do it in the main
page (the ASPX that houses the ASCX) load event it works fine, but if I do
it in the Page Load event of the ASCX itself it gets weird results...
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
If Not Request.Cookies("My_FullName") Is Nothing Then
If Request.Cookies("My_FullName").Value <> vbNullString Then
lblUser.Text = "<br>Logged in as:<br>" &
Request.Cookies("My_FullName").Value & "<br>"
Else
lblUser.Text = vbNullString
End If
Else
lblUser.Text = vbNullString
End If
End Sub
What *appears* to be happening is that the content of the ASCX is rendered
on the server so it's almost random what the value of the My_FullName cookie
is. Sometimes it's nothing, sometimes it's for a user who has never been
logged into this particular machine but is logged in at another machine,
sometimes it's correct.
Can someone please point me in the right direction to determine how ASCX's
get rendered? I'm sure it's just me not understanding the order in which
things work.
Ta
Andrew
I had a weird issue with trying to use a cookie in a ASCX housed on my web
forms and I was wondering if I am missing something.
I wanted to use the authenticated cookie for the user name logged into the
web site to show the user that they are logged on. If I do it in the main
page (the ASPX that houses the ASCX) load event it works fine, but if I do
it in the Page Load event of the ASCX itself it gets weird results...
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
If Not Request.Cookies("My_FullName") Is Nothing Then
If Request.Cookies("My_FullName").Value <> vbNullString Then
lblUser.Text = "<br>Logged in as:<br>" &
Request.Cookies("My_FullName").Value & "<br>"
Else
lblUser.Text = vbNullString
End If
Else
lblUser.Text = vbNullString
End If
End Sub
What *appears* to be happening is that the content of the ASCX is rendered
on the server so it's almost random what the value of the My_FullName cookie
is. Sometimes it's nothing, sometimes it's for a user who has never been
logged into this particular machine but is logged in at another machine,
sometimes it's correct.
Can someone please point me in the right direction to determine how ASCX's
get rendered? I'm sure it's just me not understanding the order in which
things work.
Ta
Andrew